blob: 14f67562c6cf19d2ad48357ce88871da9cfa45e6 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Deepthi Gowri4480a3f2016-05-18 19:30:17 +05302 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
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.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam0fb93dd2014-02-19 00:32:59 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/** ------------------------------------------------------------------------- *
29 ------------------------------------------------------------------------- *
30
31
32 \file csrNeighborRoam.c
33
34 Implementation for the simple roaming algorithm for 802.11r Fast transitions and Legacy roaming for Android platform.
35
36 Copyright (C) 2010 Qualcomm, Incorporated
37
38
39 ========================================================================== */
40
41/*===========================================================================
42
43 EDIT HISTORY FOR FILE
44
45
46 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
49
50
51 when who what, where, why
52---------- --- --------------------------------------------------------
5308/01/10 Murali Created
54
55===========================================================================*/
56#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
57#include "wlan_qct_wda.h"
58#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smsDebug.h"
61#include "logDump.h"
62#include "smeQosInternal.h"
63#include "wlan_qct_tl.h"
64#include "smeInside.h"
65#include "vos_diag_core_event.h"
66#include "vos_diag_core_log.h"
67#include "csrApi.h"
68#include "wlan_qct_tl.h"
69#include "sme_Api.h"
70#include "csrNeighborRoam.h"
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +053071#include "macTrace.h"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080072#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
73#include "csrEse.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#endif
75
76#define WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG 1
77#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG
78#define NEIGHBOR_ROAM_DEBUG smsLog
79#else
80#define NEIGHBOR_ROAM_DEBUG(x...)
81#endif
82
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -070083static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo);
84static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac);
85static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac);
86static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac);
87
Jeff Johnson295189b2012-06-20 16:38:30 -070088VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -080089 v_PVOID_t pUserCtxt,
90 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070091VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -080092 v_PVOID_t pUserCtxt,
93 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070094void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus);
95eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile );
96
97#ifdef WLAN_FEATURE_VOWIFI_11R
98static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac);
99VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac);
100#endif
101
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800102v_U8_t *csrNeighborRoamStateToString(v_U8_t state)
103{
104 switch(state)
105 {
Daram Sudha1f7e0e92013-12-17 07:52:31 +0530106 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CLOSED );
107 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_INIT );
108 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CONNECTED );
109 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN );
110 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING );
111 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY );
112 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN );
113 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING );
114 CASE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE );
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800115 default:
116 return "eCSR_NEIGHBOR_ROAM_STATE_UNKNOWN";
117 }
118
119}
120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121/* State Transition macro */
122#define CSR_NEIGHBOR_ROAM_STATE_TRANSITION(newState)\
123{\
124 pMac->roam.neighborRoamInfo.prevNeighborRoamState = pMac->roam.neighborRoamInfo.neighborRoamState;\
125 pMac->roam.neighborRoamInfo.neighborRoamState = newState;\
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800126 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, \
127 FL("Neighbor Roam Transition from state %s ==> %s"), \
128 csrNeighborRoamStateToString (pMac->roam.neighborRoamInfo.prevNeighborRoamState), \
129 csrNeighborRoamStateToString (newState));\
Jeff Johnson295189b2012-06-20 16:38:30 -0700130}
131
132/* ---------------------------------------------------------------------------
133
134 \fn csrNeighborRoamFreeNeighborRoamBSSNode
135
136 \brief This function frees all the internal pointers CSR NeighborRoam BSS Info
137 and also frees the node itself
138
139 \param pMac - The handle returned by macOpen.
140 neighborRoamBSSNode - Neighbor Roam BSS Node to be freed
141
142 \return VOID
143
144---------------------------------------------------------------------------*/
145void csrNeighborRoamFreeNeighborRoamBSSNode(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo neighborRoamBSSNode)
146{
147 if (neighborRoamBSSNode)
148 {
149 if (neighborRoamBSSNode->pBssDescription)
150 {
151 vos_mem_free(neighborRoamBSSNode->pBssDescription);
152 neighborRoamBSSNode->pBssDescription = NULL;
153 }
154 vos_mem_free(neighborRoamBSSNode);
155 neighborRoamBSSNode = NULL;
156 }
157
158 return;
159}
160
161/* ---------------------------------------------------------------------------
162
163 \fn csrNeighborRoamRemoveRoamableAPListEntry
164
165 \brief This function removes a given entry from the given list
166
167 \param pMac - The handle returned by macOpen.
168 pList - The list from which the entry should be removed
169 pNeighborEntry - Neighbor Roam BSS Node to be removed
170
171 \return TRUE if successfully removed, else FALSE
172
173---------------------------------------------------------------------------*/
174tANI_BOOLEAN csrNeighborRoamRemoveRoamableAPListEntry(tpAniSirGlobal pMac,
175 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
176{
177 if(pList)
178 {
179 return csrLLRemoveEntry(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
180 }
181
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800182 smsLog(pMac, LOGE, FL("Removing neighbor BSS node from list failed. Current count = %d"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700183
184 return eANI_BOOLEAN_FALSE;
185}
186
187/* ---------------------------------------------------------------------------
188
189 \fn csrNeighborRoamGetRoamableAPListNextEntry
190
191 \brief Gets the entry next to passed entry. If NULL is passed, return the entry in the head of the list
192
193 \param pMac - The handle returned by macOpen.
194 pList - The list from which the entry should be returned
195 pNeighborEntry - Neighbor Roam BSS Node whose next entry should be returned
196
197 \return Neighbor Roam BSS Node to be returned
198
199---------------------------------------------------------------------------*/
200tpCsrNeighborRoamBSSInfo csrNeighborRoamGetRoamableAPListNextEntry(tpAniSirGlobal pMac,
201 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
202{
203 tListElem *pEntry = NULL;
204 tpCsrNeighborRoamBSSInfo pResult = NULL;
205
206 if(pList)
207 {
208 if(NULL == pNeighborEntry)
209 {
210 pEntry = csrLLPeekHead(pList, LL_ACCESS_LOCK);
211 }
212 else
213 {
214 pEntry = csrLLNext(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
215 }
216 if(pEntry)
217 {
218 pResult = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
219 }
220 }
221
222 return pResult;
223}
224
225/* ---------------------------------------------------------------------------
226
227 \fn csrNeighborRoamFreeRoamableBSSList
228
229 \brief Empties and frees all the nodes in the roamable AP list
230
231 \param pMac - The handle returned by macOpen.
232 pList - Neighbor Roam BSS List to be emptied
233
234 \return VOID
235
236---------------------------------------------------------------------------*/
237void csrNeighborRoamFreeRoamableBSSList(tpAniSirGlobal pMac, tDblLinkList *pList)
238{
239 tpCsrNeighborRoamBSSInfo pResult = NULL;
240
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800241 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Emptying the BSS list. Current count = %d"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700242
243 /* Pick up the head, remove and free the node till the list becomes empty */
244 while ((pResult = csrNeighborRoamGetRoamableAPListNextEntry(pMac, pList, NULL)) != NULL)
245 {
246 csrNeighborRoamRemoveRoamableAPListEntry(pMac, pList, pResult);
247 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pResult);
248 }
249 return;
250}
251
Mukul Sharmac353a5b2015-01-16 20:49:12 +0530252static eHalStatus csrNeighborRoamTriggerHandoff(tpAniSirGlobal pMac,
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800253 tpCsrNeighborRoamControlInfo pNeighborRoamInfo)
254{
Mukul Sharmac353a5b2015-01-16 20:49:12 +0530255 eHalStatus status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800256#ifdef WLAN_FEATURE_VOWIFI_11R
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700257 if ((pNeighborRoamInfo->is11rAssoc)
258#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
259 && !csrRoamIsRoamOffloadScanEnabled(pMac)
260#endif
261 )
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800262 {
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +0530263 if ((eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState) ||
264 (eSME_ROAM_TRIGGER_FAST_ROAM == pNeighborRoamInfo->cfgRoamEn))
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800265 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +0530266 status = csrNeighborRoamIssuePreauthReq(pMac);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +0530267 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_NONE;
268 vos_mem_set(&pNeighborRoamInfo->cfgRoambssId[0],
269 sizeof(pNeighborRoamInfo->cfgRoambssId),
270 0xFF);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800271 }
272 else
273 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +0530274 smsLog(pMac, LOGE, FL("11R Reassoc indication received in"
275 "unexpected state %s"),
276 macTraceGetNeighbourRoamState(
277 pNeighborRoamInfo->neighborRoamState));
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800278 VOS_ASSERT(0);
279 }
280 }
281 else
282#endif
283
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800284#ifdef FEATURE_WLAN_ESE
285 if ((pNeighborRoamInfo->isESEAssoc)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700286#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
287 && !csrRoamIsRoamOffloadScanEnabled(pMac)
288#endif
289 )
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800290 {
291 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
292 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +0530293 status = csrNeighborRoamIssuePreauthReq(pMac);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800294 }
295 else
296 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800297 smsLog(pMac, LOGE, FL("ESE Reassoc indication received in unexpected state %s"),
298 macTraceGetNeighbourRoamState(pNeighborRoamInfo->neighborRoamState));
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800299 VOS_ASSERT(0);
300 }
301 }
302 else
303#endif
304#ifdef FEATURE_WLAN_LFR
305 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
306 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700307 if ((eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
308#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +0530309 || csrRoamIsRoamOffloadScanEnabled(pMac) ||
310 (eSME_ROAM_TRIGGER_FAST_ROAM == pNeighborRoamInfo->cfgRoamEn)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700311#endif
312 )
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800313 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +0530314 status = csrNeighborRoamIssuePreauthReq(pMac);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +0530315 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_NONE;
316 vos_mem_set(&pNeighborRoamInfo->cfgRoambssId[0],
317 sizeof(pNeighborRoamInfo->cfgRoambssId),
318 0xFF);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800319 }
320 else
321 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +0530322 smsLog(pMac, LOGE, FL("LFR Reassoc indication received in"
323 "unexpected state %s"),
324 macTraceGetNeighbourRoamState(
325 pNeighborRoamInfo->neighborRoamState));
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800326 VOS_ASSERT(0);
327 }
328 }
329 else
330#endif
331 {
332 if (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pNeighborRoamInfo->neighborRoamState)
333 {
334 csrNeighborRoamRequestHandoff(pMac);
335 }
336 else
337 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +0530338 smsLog(pMac, LOGE, FL("Non-11R Reassoc indication received in"
339 "unexpected state %s or Roaming is disabled"),
340 macTraceGetNeighbourRoamState(
341 pNeighborRoamInfo->neighborRoamState));
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800342 }
343 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +0530344 return status;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800345}
346
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700347VOS_STATUS csrNeighborRoamUpdateFastRoamingEnabled(tpAniSirGlobal pMac, const v_BOOL_t fastRoamEnabled)
348{
349 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
350 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
351
352 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
353 {
354 if (VOS_TRUE == fastRoamEnabled)
355 {
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700356#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
357 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
358 {
359 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
360 } else {
361#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700362 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"),
363 pNeighborRoamInfo->currentNeighborLookupThreshold);
364 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
365 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
366 WLANTL_HO_THRESHOLD_DOWN,
367 csrNeighborRoamNeighborLookupDOWNCallback,
368 VOS_MODULE_ID_SME, pMac);
369 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
370 {
371 //err msg
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530372 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vosStatus);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700373 vosStatus = VOS_STATUS_E_FAILURE;
374 }
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700375#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
376 }
377#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700378 }
379 else if (VOS_FALSE == fastRoamEnabled)
380 {
381 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in CONNECTED state, so deregister all events"));
382 /* De-register existing lookup UP/DOWN, Rssi indications */
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700383#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
384 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
385 {
386 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP, REASON_DISCONNECTED);
387 } else {
388#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700389 csrNeighborRoamDeregAllRssiIndication(pMac);
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700390#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
391 }
392#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700393 }
394 }
395 else if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
396 {
397 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in INIT state, Nothing to do"));
398 }
399 else
400 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +0530401 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
402 FL("Unexpected state %s, returning failure"),
403 macTraceGetNeighbourRoamState(
404 pNeighborRoamInfo->neighborRoamState));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700405 vosStatus = VOS_STATUS_E_FAILURE;
406 }
407 return vosStatus;
408}
409
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800410#ifdef FEATURE_WLAN_ESE
411VOS_STATUS csrNeighborRoamUpdateEseModeEnabled(tpAniSirGlobal pMac, const v_BOOL_t eseMode)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700412{
413 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
414 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
415
416 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
417 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800418 if (VOS_TRUE == eseMode)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700419 {
420 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"),
421 pNeighborRoamInfo->currentNeighborLookupThreshold);
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700422#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
423 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
424 {
425 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
426 } else {
427#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700428 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
429 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
430 WLANTL_HO_THRESHOLD_DOWN,
431 csrNeighborRoamNeighborLookupDOWNCallback,
432 VOS_MODULE_ID_SME, pMac);
433 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
434 {
435 //err msg
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530436 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vosStatus);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700437 vosStatus = VOS_STATUS_E_FAILURE;
438 }
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700439#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
440 }
441#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700442 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800443 else if (VOS_FALSE == eseMode)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700444 {
445 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in CONNECTED state, so deregister all events"));
446 /* De-register existing lookup UP/DOWN, Rssi indications */
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700447#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
448 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
449 {
450 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP, REASON_DISCONNECTED);
451 } else {
452#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700453 csrNeighborRoamDeregAllRssiIndication(pMac);
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700454#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
455 }
456#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700457 }
458 }
459 else if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
460 {
461 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in INIT state, Nothing to do"));
462 }
463 else
464 {
465 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Unexpected state %d, returning failure"), pNeighborRoamInfo->neighborRoamState);
466 vosStatus = VOS_STATUS_E_FAILURE;
467 }
468 return vosStatus;
469}
470
471#endif
472
473
Srinivas Girigowdade697412013-02-14 16:31:48 -0800474VOS_STATUS csrNeighborRoamSetLookupRssiThreshold(tpAniSirGlobal pMac, v_U8_t neighborLookupRssiThreshold)
475{
476 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
477 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
478
479 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
480 {
481 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in CONNECTED state, so deregister all and re-register for DOWN event again"));
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700482
483 pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold = neighborLookupRssiThreshold;
484 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
485
Srinivas Girigowdade697412013-02-14 16:31:48 -0800486 /* De-register existing lookup UP/DOWN, Rssi indications */
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -0700487#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
488 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
489 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700490 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_LOOKUP_THRESH_CHANGED);
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -0700491 }
492 else
493 {
494#endif
495 csrNeighborRoamDeregAllRssiIndication(pMac);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800496
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -0700497 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
498 FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"),
499 pNeighborRoamInfo->currentNeighborLookupThreshold);
500 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
501 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
502 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
503 WLANTL_HO_THRESHOLD_DOWN,
504 csrNeighborRoamNeighborLookupDOWNCallback,
505 VOS_MODULE_ID_SME, pMac);
506 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
507 {
508 //err msg
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530509 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vosStatus);
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -0700510 vosStatus = VOS_STATUS_E_FAILURE;
511 }
512#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
513 }
514#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -0800515 }
516 else if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
517 {
518 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in INIT state, safe to set lookupRssi threshold"));
519 pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold = neighborLookupRssiThreshold;
520 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
521 }
522 else
523 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +0530524 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
525 FL("Unexpected state %s, returning failure"),
526 macTraceGetNeighbourRoamState(pNeighborRoamInfo->neighborRoamState));
Srinivas Girigowdade697412013-02-14 16:31:48 -0800527 vosStatus = VOS_STATUS_E_FAILURE;
528 }
529 return vosStatus;
530}
531
Jeff Johnson295189b2012-06-20 16:38:30 -0700532/* ---------------------------------------------------------------------------
533
534 \fn csrNeighborRoamReassocIndCallback
535
536 \brief Reassoc callback invoked by TL on crossing the registered re-assoc threshold.
537 Directly triggere HO in case of non-11r association
538 In case of 11R association, triggers a pre-auth eventually followed by actual HO
539
540 \param pAdapter - VOS Context
541 trafficStatus - UP/DOWN indication from TL
542 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
543
544 \return VOID
545
546---------------------------------------------------------------------------*/
547VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter,
548 v_U8_t trafficStatus,
Srinivasdaaec712012-12-12 15:59:44 -0800549 v_PVOID_t pUserCtxt,
550 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700551{
552 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
553 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
554 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +0530555
556 if (eSME_ROAM_TRIGGER_FAST_ROAM != pNeighborRoamInfo->cfgRoamEn)
557 {
558 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. Threshold RSSI = %d Reported RSSI = %d"),
Srinivasdaaec712012-12-12 15:59:44 -0800559 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
560 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700561
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +0530562 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 WLANTL_HO_THRESHOLD_DOWN,
564 csrNeighborRoamReassocIndCallback,
565 VOS_MODULE_ID_SME);
566
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +0530567 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
568 {
569 //err msg
570 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
571 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700572
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +0530573 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. Threshold RSSI = %d Reported RSSI = %d"),
574 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1), avgRssi);
575 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
576 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
577 WLANTL_HO_THRESHOLD_UP,
578 csrNeighborRoamNeighborLookupUPCallback,
579 VOS_MODULE_ID_SME);
580
581 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
582 {
583 //err msg
584 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamNeighborLookupUPCallback with TL: Status = %d"), vosStatus);
585 }
586 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 /* We dont need to run this timer any more. */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530588 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
589 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700590
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800591 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 return VOS_STATUS_SUCCESS;
594}
595
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700596/*CleanUP Routines*/
597static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo)
598{
599 if ((rChInfo->IAPPNeighborListReceived == FALSE) &&
600 (rChInfo->currentChannelListInfo.numOfChannels))
601 {
602 rChInfo->currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
603 rChInfo->currentChannelListInfo.numOfChannels = 0;
604
605 if (rChInfo->currentChannelListInfo.ChannelList)
606 vos_mem_free(rChInfo->currentChannelListInfo.ChannelList);
607
608 rChInfo->currentChannelListInfo.ChannelList = NULL;
609 rChInfo->chanListScanInProgress = eANI_BOOLEAN_FALSE;
610 }
611 else
612 {
613 rChInfo->currentChanIndex = 0;
614 rChInfo->chanListScanInProgress = eANI_BOOLEAN_TRUE;
615 }
616}
617
618static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac)
619{
620 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
621
622 /* Stop neighbor scan timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530623 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700624
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700625 /* Stop neighbor scan results refresh timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530626 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700627
Srinivas Girigowdade697412013-02-14 16:31:48 -0800628 /* Stop empty scan results refresh timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530629 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800630
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700631 /* Abort any ongoing scan */
632 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
633 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +0530634 csrScanAbortMacScan(pMac, pNeighborRoamInfo->csrSessionId,
635 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700636 }
637 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
638
639 /* Reset roam channel list information */
640 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
641}
642
643static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac)
644{
645 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
646
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800647#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700648 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700649 /* Purge pre-auth fail list */
650 csrNeighborRoamPurgePreauthFailedList(pMac);
651#endif
652
653 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
654 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
655#ifdef WLAN_FEATURE_VOWIFI_11R
656 /* Do not free up the preauth done list here */
657 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
658 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
659 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
660 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700661#endif
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -0700662#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
663 pNeighborRoamInfo->uOsRequestedHandoff = 0;
Mukul Sharma9da30f52014-12-05 21:02:56 +0530664 pNeighborRoamInfo->isForcedInitialRoamTo5GH = 0;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -0700665 vos_mem_zero(&pNeighborRoamInfo->handoffReqInfo, sizeof(tCsrHandoffRequest));
666#endif
667
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700668}
669
670static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac)
671{
672 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
673 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
674
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800675 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700676 FL("Deregister neighbor lookup UP callback with TL. RSSI = %d"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800677 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700678
679 /* Deregister reassoc callback. Ignore return status */
680 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800681 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700682 WLANTL_HO_THRESHOLD_UP,
683 csrNeighborRoamNeighborLookupUPCallback,
684 VOS_MODULE_ID_SME);
685
686 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800688 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700689 FL("Couldn't deregister csrNeighborRoamNeighborLookupUPCallback "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800690 "with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700691 }
692
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800693 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700694 FL("Deregistering reassoc DOWN callback with TL. RSSI = %d"),
695 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
696
697 /* Deregister reassoc callback. Ignore return status */
698 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
699 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
700 WLANTL_HO_THRESHOLD_DOWN,
701 csrNeighborRoamReassocIndCallback,
702 VOS_MODULE_ID_SME);
703
704 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800706 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700707 FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800708 "TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700709 }
710
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800711 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700712 FL("Deregistering neighborLookup DOWN callback with TL. RSSI = %d"),
713 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
714
715 /* Deregister neighbor lookup callback. Ignore return status */
716 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
717 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
718 WLANTL_HO_THRESHOLD_DOWN,
719 csrNeighborRoamNeighborLookupDOWNCallback,
720 VOS_MODULE_ID_SME);
721
722 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
723 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800724 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700725 FL(" Couldn't deregister csrNeighborRoamNeighborLookupDOWNCallback "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800726 "with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700727 }
728
729 /* Reset thresholds only after deregistering DOWN event from TL */
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700730 pNeighborRoamInfo->currentNeighborLookupThreshold =
731 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800732#ifdef FEATURE_WLAN_LFR
733 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -0800734 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -0800735 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800736#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700737}
738
Jeff Johnson295189b2012-06-20 16:38:30 -0700739/* ---------------------------------------------------------------------------
740
741 \fn csrNeighborRoamResetConnectedStateControlInfo
742
743 \brief This function will reset the neighbor roam control info data structures.
744 This function should be invoked whenever we move to CONNECTED state from
745 any state other than INIT state
746
747 \param pMac - The handle returned by macOpen.
748
749 \return VOID
750
751---------------------------------------------------------------------------*/
752void csrNeighborRoamResetConnectedStateControlInfo(tpAniSirGlobal pMac)
753{
754 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
755
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700756 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700759 /* We dont need to run this timer any more. */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530760 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
761 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700762
763#ifdef WLAN_FEATURE_VOWIFI_11R
764 /* Do not free up the preauth done list here */
765 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
766 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
767 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
768 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
769 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = 0;
770 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
Jeff Johnson295189b2012-06-20 16:38:30 -0700771#endif
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -0700772#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
773 pNeighborRoamInfo->uOsRequestedHandoff = 0;
Mukul Sharma9da30f52014-12-05 21:02:56 +0530774 pNeighborRoamInfo->isForcedInitialRoamTo5GH = 0;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -0700775 vos_mem_zero(&pNeighborRoamInfo->handoffReqInfo, sizeof(tCsrHandoffRequest));
776#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700777}
778
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700779void csrNeighborRoamResetReportScanStateControlInfo(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700780{
781 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
783 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800784#ifdef FEATURE_WLAN_ESE
785 pNeighborRoamInfo->isESEAssoc = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 pNeighborRoamInfo->isVOAdmitted = eANI_BOOLEAN_FALSE;
787 pNeighborRoamInfo->MinQBssLoadRequired = 0;
788#endif
Madan Mohan Koyyalamudi595208a2012-10-05 12:48:38 -0700789
790 /* Stop scan refresh timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530791 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800792 /* Stop empty scan results refresh timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530793 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700794 /* Purge roamable AP list */
795 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 return;
797}
798
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700799/* ---------------------------------------------------------------------------
800
801 \fn csrNeighborRoamResetInitStateControlInfo
802
803 \brief This function will reset the neighbor roam control info data structures.
804 This function should be invoked whenever we move to CONNECTED state from
805 INIT state
806
807 \param pMac - The handle returned by macOpen.
808
809 \return VOID
810
811---------------------------------------------------------------------------*/
812void csrNeighborRoamResetInitStateControlInfo(tpAniSirGlobal pMac)
813{
814 csrNeighborRoamResetConnectedStateControlInfo(pMac);
815
816 /* In addition to the above resets, we should clear off the curAPBssId/Session ID in the timers */
817 csrNeighborRoamResetReportScanStateControlInfo(pMac);
818}
819
820
821
Jeff Johnson295189b2012-06-20 16:38:30 -0700822#ifdef WLAN_FEATURE_VOWIFI_11R
823/* ---------------------------------------------------------------------------
824
825 \fn csrNeighborRoamBssIdScanFilter
826
827 \brief This API is used to prepare a filter to obtain scan results when
828 we complete the scan in the REPORT_SCAN state after receiving a
829 valid neighbor report from AP. This filter includes BSSIDs received from
830 the neighbor report from the AP in addition to the other filter parameters
831 created from connected profile
832
833 \param pMac - The handle returned by macOpen.
834 pScanFilter - Scan filter to be filled and returned
835
836 \return eHAL_STATUS_SUCCESS on succesful filter creation, corresponding error
837 code otherwise
838
839---------------------------------------------------------------------------*/
840static eHalStatus csrNeighborRoamBssIdScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
841{
842 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
843 tANI_U8 i = 0;
844
845 VOS_ASSERT(pScanFilter != NULL);
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +0530846 if (pScanFilter == NULL)
847 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
849
850 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
851 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
852 if (NULL == pScanFilter->BSSIDs.bssid)
853 {
854 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
855 return eHAL_STATUS_FAILED_ALLOC;
856 }
857
858 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
859
860 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
861 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
862 {
863 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
864 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
865 }
866
867 /* Fill other general scan filter params */
868 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
869}
870
871/* ---------------------------------------------------------------------------
872
873 \fn csrNeighborRoamPurgePreauthFailList
874
875 \brief This function empties the preauth fail list
876
877 \param pMac - The handle returned by macOpen.
878
879 \return VOID
880
881---------------------------------------------------------------------------*/
882void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
883{
884 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
885
886 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
887 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
888 {
889 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
890 sizeof(tSirMacAddr));
891 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
892 }
893 return;
894}
895
896/* ---------------------------------------------------------------------------
897
898 \fn csrNeighborRoamAddBssIdToPreauthFailList
899
900 \brief This function adds the given BSSID to the Preauth fail list
901
902 \param pMac - The handle returned by macOpen.
903 bssId - BSSID to be added to the preauth fail list
904
905 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
906
907---------------------------------------------------------------------------*/
908eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
909{
910 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
911
Arif Hussain24bafea2013-11-15 15:10:03 -0800912 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL(" Added BSSID "MAC_ADDRESS_STR" to Preauth failed list"),
913 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700914
915
916 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
917 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
918 {
919 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
920 return eHAL_STATUS_FAILURE;
921 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530922 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[
923 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
924 bssId,
925 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
927
928 return eHAL_STATUS_SUCCESS;
929}
930
931/* ---------------------------------------------------------------------------
932
933 \fn csrNeighborRoamIsPreauthCandidate
934
935 \brief This function checks whether the given MAC address is already
936 present in the preauth fail list and returns TRUE/FALSE accordingly
937
938 \param pMac - The handle returned by macOpen.
939
940 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
941
942---------------------------------------------------------------------------*/
943tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
944{
945 tANI_U8 i = 0;
946 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
947
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700948#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
949 if (csrRoamIsRoamOffloadScanEnabled(pMac))
950 {
951 return eANI_BOOLEAN_TRUE;
952 }
953#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
955 return eANI_BOOLEAN_TRUE;
956
957 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
958 {
959 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
960 bssId, sizeof(tSirMacAddr)))
961 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800962 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID "MAC_ADDRESS_STR" already present in preauth fail list"),
963 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 return eANI_BOOLEAN_FALSE;
965 }
966 }
967
968 return eANI_BOOLEAN_TRUE;
969}
970
971/* ---------------------------------------------------------------------------
972
973 \fn csrNeighborRoamIssuePreauthReq
974
975 \brief This function issues preauth request to PE with the 1st AP entry in the
976 roamable AP list
977
978 \param pMac - The handle returned by macOpen.
979
980 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
981
982---------------------------------------------------------------------------*/
983static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
984{
985 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
986 eHalStatus status = eHAL_STATUS_SUCCESS;
987 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
Yue Maef608272013-04-08 23:09:17 -0700988
989#ifdef FEATURE_WLAN_LFR_METRICS
990 tCsrRoamInfo *roamInfo;
991#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700992
993 /* This must not be true here */
994 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
995
996 /* Issue Preauth request to PE here */
997 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
998 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
999 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
1000 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
1001
1002 if (NULL == pNeighborBssNode)
1003 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05301004 smsLog(pMac, LOGW, FL("Roamable AP list is empty.. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 return eHAL_STATUS_FAILURE;
1006 }
1007 else
1008 {
Yue Maef608272013-04-08 23:09:17 -07001009#ifdef FEATURE_WLAN_LFR_METRICS
1010 /* LFR metrics - pre-auth initiation metric.
1011 Send the event to supplicant that pre-auth was initiated */
1012 roamInfo = vos_mem_malloc(sizeof(tCsrRoamInfo));
1013 if (NULL == roamInfo)
1014 {
1015 smsLog(pMac, LOG1, FL("Memory allocation failed!"));
1016 }
1017 else
1018 {
1019 vos_mem_copy((void *)roamInfo->bssid,
1020 (void *)pNeighborBssNode->pBssDescription->bssId,
1021 sizeof(tCsrBssid));
1022 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
1023 roamInfo, 0, eCSR_ROAM_PREAUTH_INIT_NOTIFY, 0);
Mukul Sharmabff8d722014-07-22 18:39:05 +05301024 vos_mem_free(roamInfo);
Yue Maef608272013-04-08 23:09:17 -07001025 }
1026#endif
1027
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001028 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
1029 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301030
Arif Hussain24bafea2013-11-15 15:10:03 -08001031 smsLog(pMac, LOG1, FL("Before Pre-Auth: BSSID "MAC_ADDRESS_STR", Ch:%d"),
1032 MAC_ADDR_ARRAY(pNeighborBssNode->pBssDescription->bssId),
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001033 (int)pNeighborBssNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301034
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 if (eHAL_STATUS_SUCCESS != status)
1036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001037 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 return status;
1039 }
1040 }
1041
1042 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
1043
1044 /* Increment the preauth retry count */
1045 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
1046
1047 /* Transition the state to preauthenticating */
1048 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Jeff Johnson295189b2012-06-20 16:38:30 -07001049
1050 return status;
1051}
1052
1053/* ---------------------------------------------------------------------------
1054
1055 \fn csrNeighborRoamPreauthRspHandler
1056
1057 \brief This function handle the Preauth response from PE
1058 Every preauth is allowed max 3 tries if it fails. If a bssid failed
1059 for more than MAX_TRIES, we will remove it from the list and try
1060 with the next node in the roamable AP list and add the BSSID to pre-auth failed
1061 list. If no more entries present in
1062 roamable AP list, transition to REPORT_SCAN state
1063
1064 \param pMac - The handle returned by macOpen.
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001065 limStatus - eSIR_SUCCESS/eSIR_FAILURE/eSIR_LIM_MAX_STA_REACHED_ERROR/
1066 eSIT_LIM_AUTH_RSP_TIMEOUT status from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07001067
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001068 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
1069 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -07001070
1071---------------------------------------------------------------------------*/
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001072eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, tSirRetStatus limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001073{
1074 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1075 eHalStatus status = eHAL_STATUS_SUCCESS;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001076 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001077 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Abhishek Singh07e4a892015-11-23 11:29:57 +05301079 tCsrRoamSession *pSession;
Yue Maef608272013-04-08 23:09:17 -07001080#ifdef FEATURE_WLAN_LFR_METRICS
1081 tCsrRoamInfo *roamInfo;
1082#endif
1083
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001084 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
1085 {
1086
1087 /* This can happen when we disconnect immediately
1088 * after sending a pre-auth request. During processing
1089 * of the disconnect command, we would have reset
1090 * preauthRspPending and transitioned to INIT state.
1091 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001092 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
1093 FL("Unexpected pre-auth response in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001094 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001095 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001096 goto DEQ_PREAUTH;
1097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001098
1099 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
1101 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
1102 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05301103 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
1104 FL("Preauth response received in state %s"),
1105 macTraceGetNeighbourRoamState(
1106 pNeighborRoamInfo->neighborRoamState));
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001107 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001108 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 }
1110
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001111 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001112
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001113 if (eSIR_SUCCESS == limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 {
1115 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
1116 }
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001117 if ((eSIR_SUCCESS == limStatus) && (NULL != pPreauthRspNode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001119 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Preauth completed successfully after %d tries"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
Jeff Johnson295189b2012-06-20 16:38:30 -07001120
Arif Hussain24bafea2013-11-15 15:10:03 -08001121 smsLog(pMac, LOG1, FL("After Pre-Auth: BSSID "MAC_ADDRESS_STR", Ch:%d"),
1122 MAC_ADDR_ARRAY(pPreauthRspNode->pBssDescription->bssId),
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001123 (int)pPreauthRspNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301124
Yue Maef608272013-04-08 23:09:17 -07001125#ifdef FEATURE_WLAN_LFR_METRICS
1126 /* LFR metrics - pre-auth completion metric.
1127 Send the event to supplicant that pre-auth successfully completed */
1128 roamInfo = vos_mem_malloc(sizeof(tCsrRoamInfo));
1129 if (NULL == roamInfo)
1130 {
1131 smsLog(pMac, LOG1, FL("Memory allocation failed!"));
1132 }
1133 else
1134 {
1135 vos_mem_copy((void *)roamInfo->bssid,
1136 (void *)pPreauthRspNode->pBssDescription->bssId,
1137 sizeof(tCsrBssid));
1138 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
1139 roamInfo, 0, eCSR_ROAM_PREAUTH_STATUS_SUCCESS, 0);
Mukul Sharmabff8d722014-07-22 18:39:05 +05301140 vos_mem_free(roamInfo);
Yue Maef608272013-04-08 23:09:17 -07001141 }
1142#endif
1143
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
1145 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
1146 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
1147
1148 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
1149 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
1150 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
1151
1152 /* The caller of this function would start a timer and by the time it expires, supplicant should
1153 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
1154 }
1155 else
1156 {
1157 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
1158 tListElem *pEntry;
1159
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001160 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = 0x%x"),
1161 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, limStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001162
1163 /* Preauth failed. Add the bssId to the preAuth failed list MAC Address. Also remove the AP from roamable AP list */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001164 if ((pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >=
1165 CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES) ||
1166 (eSIR_LIM_MAX_STA_REACHED_ERROR == limStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 {
1168 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
1169 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
1170
1171 /* The one in the head of the list should be one with which we issued pre-auth and failed */
1172 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
1173 if(pEntry)
1174 {
1175 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001176 /* Add the BSSID to pre-auth fail list if it is not requested by HDD */
1177#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1178 if(!pNeighborRoamInfo->uOsRequestedHandoff)
1179#endif
1180 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001182 }
Yue Maef608272013-04-08 23:09:17 -07001183
1184#ifdef FEATURE_WLAN_LFR_METRICS
1185 /* LFR metrics - pre-auth completion metric. Send the event
1186 to supplicant that pre-auth successfully completed */
1187 roamInfo = vos_mem_malloc(sizeof(tCsrRoamInfo));
1188 if (NULL == roamInfo)
1189 {
1190 smsLog(pMac, LOG1, FL("Memory allocation failed!"));
1191 }
1192 else
1193 {
1194 vos_mem_copy((void *)roamInfo->bssid,
1195 (void *)pNeighborBssNode->pBssDescription->bssId,
1196 sizeof(tCsrBssid));
1197 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
1198 roamInfo, 0, eCSR_ROAM_PREAUTH_STATUS_FAILURE, 0);
Mukul Sharmabff8d722014-07-22 18:39:05 +05301199 vos_mem_free(roamInfo);
Yue Maef608272013-04-08 23:09:17 -07001200 }
1201#endif
1202
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 /* Now we can free this node */
1204 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
1205 }
1206 }
Abhishek Singh07e4a892015-11-23 11:29:57 +05301207 pSession = CSR_GET_SESSION(pMac, pNeighborRoamInfo->csrSessionId);
1208 if ((NULL != pSession) && pSession->abortConnection)
1209 {
1210 smsLog(pMac, LOGE, FL(" Deauth in progress Abort preauth"));
1211 goto abort_preauth;
1212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001213
1214 /* Issue preauth request for the same/next entry */
1215 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001216 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07001217
Abhishek Singh07e4a892015-11-23 11:29:57 +05301218abort_preauth:
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001219#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1220 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001221 {
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07001222 if(pNeighborRoamInfo->uOsRequestedHandoff)
1223 {
1224 pNeighborRoamInfo->uOsRequestedHandoff = 0;
1225 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_PREAUTH_FAILED_FOR_ALL);
1226 }
Mukul Sharma9da30f52014-12-05 21:02:56 +05301227 else if(pNeighborRoamInfo->isForcedInitialRoamTo5GH)
1228 {
1229 pNeighborRoamInfo->isForcedInitialRoamTo5GH = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05301230 smsLog(pMac, LOGE, FL("Forced 5G roaming preauth got failed"
1231 "send RSO START cmd to fwr."));
1232 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma9da30f52014-12-05 21:02:56 +05301233 }
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07001234 else
1235 {
1236 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_RESTART, REASON_PREAUTH_FAILED_FOR_ALL);
1237 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001238 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1239 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001241#endif
1242 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
1243
1244 /* Register Neighbor Lookup threshold callback with TL for UP event now */
1245 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
1246 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1247
1248 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1249 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1250 WLANTL_HO_THRESHOLD_UP,
1251 csrNeighborRoamNeighborLookupUPCallback,
1252 VOS_MODULE_ID_SME, pMac);
1253 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1254 {
1255 //err msg
1256 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
1257 }
1258
1259 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05301260 status = vos_timer_start(&pNeighborRoamInfo->neighborResultsRefreshTimer,
1261 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod);
1262 if ( status != eHAL_STATUS_SUCCESS )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001263 {
1264 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d"), status);
1265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001267#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001269#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001270
1271DEQ_PREAUTH:
1272 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001273 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001274}
1275#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
1276
1277/* ---------------------------------------------------------------------------
1278
1279 \fn csrNeighborRoamPrepareScanProfileFilter
1280
1281 \brief This function creates a scan filter based on the currently connected profile.
1282 Based on this filter, scan results are obtained
1283
1284 \param pMac - The handle returned by macOpen.
1285 pScanFilter - Populated scan filter based on the connected profile
1286
1287 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
1288
1289---------------------------------------------------------------------------*/
1290eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
1291{
1292 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1293 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
1294 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
1295 tANI_U8 i = 0;
1296
1297 VOS_ASSERT(pScanFilter != NULL);
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05301298 if (pScanFilter == NULL)
1299 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001300
1301 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
1302
1303 /* We dont want to set BSSID based Filter */
1304 pScanFilter->BSSIDs.numOfBSSIDs = 0;
1305
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001306 //only for HDD requested handoff fill in the BSSID in the filter
1307#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1308 if (pNeighborRoamInfo->uOsRequestedHandoff)
1309 {
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +05301310
1311 smsLog(pMac, LOG1, FL("OS Requested Handoff"));
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001312 pScanFilter->BSSIDs.numOfBSSIDs = 1;
1313 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
1314 if (NULL == pScanFilter->BSSIDs.bssid)
1315 {
1316 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
1317 return eHAL_STATUS_FAILED_ALLOC;
1318 }
1319
1320 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
1321
1322 /* Populate the BSSID from handoff info received from HDD */
1323 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
1324 {
1325 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
1326 pNeighborRoamInfo->handoffReqInfo.bssid, sizeof(tSirMacAddr));
1327 }
1328 }
1329#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 /* Populate all the information from the connected profile */
1331 pScanFilter->SSIDs.numOfSSIDs = 1;
1332 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
1333 if (NULL == pScanFilter->SSIDs.SSIDList)
1334 {
1335 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
1336 return eHAL_STATUS_FAILED_ALLOC;
1337 }
1338 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
1339 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
1340 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
1341 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
1342
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001343 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Filtering for SSID %.*s from scan results,"
Sanjay Devnani05814522013-06-24 11:46:56 -07001344 "length of SSID = %u"),
1345 pScanFilter->SSIDs.SSIDList->SSID.length,
1346 pScanFilter->SSIDs.SSIDList->SSID.ssId,
1347 pScanFilter->SSIDs.SSIDList->SSID.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 pScanFilter->authType.numEntries = 1;
1349 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
1350
1351 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
1352 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
1353
1354 pScanFilter->mcEncryptionType.numEntries = 1;
1355 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
1356
1357 pScanFilter->BSSType = pCurProfile->BSSType;
1358
Hema Aparna Medicharlaabde8a12015-04-22 17:26:50 +05301359 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 {
Hema Aparna Medicharlaabde8a12015-04-22 17:26:50 +05301361 /* We are intrested only in the scan results on channels that we scanned */
1362 pScanFilter->ChannelInfo.numOfChannels =
1363 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
1364 pScanFilter->ChannelInfo.ChannelList =
1365 vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
1366 if (NULL == pScanFilter->ChannelInfo.ChannelList)
1367 {
1368 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
1369 vos_mem_free(pScanFilter->SSIDs.SSIDList);
1370 pScanFilter->SSIDs.SSIDList = NULL;
1371 return eHAL_STATUS_FAILED_ALLOC;
1372 }
1373 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
1374 {
1375 pScanFilter->ChannelInfo.ChannelList[i] =
1376 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
1377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 }
Hema Aparna Medicharlaabde8a12015-04-22 17:26:50 +05301379 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 {
Hema Aparna Medicharlaabde8a12015-04-22 17:26:50 +05301381 pScanFilter->ChannelInfo.numOfChannels = 0;
1382 pScanFilter->ChannelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 }
Kapil Guptab3a981b2016-06-26 13:36:51 +05301384#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1385 if (pMac->PERroamCandidatesCnt)
1386 pScanFilter->isPERRoamScan = true;
1387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001388#ifdef WLAN_FEATURE_VOWIFI_11R
1389 if (pNeighborRoamInfo->is11rAssoc)
1390 {
1391 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
1392 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
1393 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
1394 }
1395#endif
1396
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05301397#ifdef WLAN_FEATURE_11W
1398 pScanFilter->MFPEnabled = pCurProfile->MFPEnabled;
1399 pScanFilter->MFPRequired = pCurProfile->MFPRequired;
1400 pScanFilter->MFPCapable = pCurProfile->MFPCapable;
1401#endif
1402
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 return eHAL_STATUS_SUCCESS;
1404}
1405
Jeff Johnson43971f52012-07-17 12:26:56 -07001406tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1407{
1408 tCsrScanResultInfo *pScanResult;
1409 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda2efea0e2013-01-24 17:40:41 -08001410#ifdef FEATURE_WLAN_LFR
1411 tANI_U32 CurrAPRssi = pNeighborRoamInfo->lookupDOWNRssi;
1412#else
1413 /* We are setting this as default value to make sure we return this value,
1414 when we do not see this AP in the scan result for some reason.However,it is
1415 less likely that we are associated to an AP and do not see it in the scan list */
1416 tANI_U32 CurrAPRssi = -125;
1417#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07001418
1419 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1420 {
1421
1422 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1423 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1424 {
1425 /* We got a match with the currently associated AP.
1426 * Capture the RSSI value and complete the while loop.
1427 * The while loop is completed in order to make the current entry go back to NULL,
1428 * and in the next while loop, it properly starts searching from the head of the list.
1429 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1430
1431 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1432
1433 } else {
1434 continue;
1435 }
1436 }
1437
1438 return CurrAPRssi;
1439
1440}
1441
Jeff Johnson295189b2012-06-20 16:38:30 -07001442/* ---------------------------------------------------------------------------
1443
1444 \fn csrNeighborRoamProcessScanResults
1445
1446 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1447 Assumed that the results are already sorted by RSSI by csrScanGetResult
1448
1449 \param pMac - The handle returned by macOpen.
1450 pScanResultList - Scan result result obtained from csrScanGetResult()
1451
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001452 \return tANI_BOOLEAN - return TRUE if we have a candidate we can immediately
1453 roam to. Otherwise, return FALSE.
Jeff Johnson295189b2012-06-20 16:38:30 -07001454
1455---------------------------------------------------------------------------*/
1456
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001457static tANI_BOOLEAN csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac,
1458 tScanResultHandle *pScanResultList)
Jeff Johnson295189b2012-06-20 16:38:30 -07001459{
1460 tCsrScanResultInfo *pScanResult;
1461 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1462 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001463 tANI_U32 CurrAPRssi;
1464 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001465#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001466 tANI_U8 immediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1467#endif
1468 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Jeff Johnson43971f52012-07-17 12:26:56 -07001469
1470 /***************************************************************
1471 * Find out the Current AP RSSI and keep it handy to check if
1472 * it is better than the RSSI of the AP which we are
1473 * going to roam.If so, we are going to continue with the
1474 * current AP.
1475 ***************************************************************/
1476 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001477
1478 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1479 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1480 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1481 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1482 /* 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
1483 and rssi score are in the same order. This will be taken care later */
1484
1485 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1486 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001487 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Arif Hussain24bafea2013-11-15 15:10:03 -08001488 FL("Scan result: BSSID "MAC_ADDRESS_STR" (Rssi %ld, Ch:%d)"),
1489 MAC_ADDR_ARRAY(pScanResult->BssDescriptor.bssId),
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001490 abs(pScanResult->BssDescriptor.rssi),
1491 pScanResult->BssDescriptor.channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001492
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05301493 if ((VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1494 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr))) ||
1495 ((eSME_ROAM_TRIGGER_SCAN == pNeighborRoamInfo->cfgRoamEn) &&
1496 (VOS_TRUE != vos_mem_compare(pScanResult->BssDescriptor.bssId,
1497 pNeighborRoamInfo->cfgRoambssId, sizeof(tSirMacAddr)))))
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001499 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001500 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001501 "SKIP-currently associated AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 continue;
1503 }
1504
Abhishek Singh93d8fa32016-03-21 17:40:10 +05301505 if (vos_concurrent_open_sessions_running() &&
1506 !pMac->roam.configParam.fenableMCCMode &&
1507 (pScanResult->BssDescriptor.channelId !=
1508 csrGetConcurrentOperationChannel(pMac))) {
1509 smsLog(pMac, LOG1, FL("MCC not supported so Ignore AP on channel %d"),
1510 pScanResult->BssDescriptor.channelId);
1511 continue;
1512 }
1513
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07001514#ifdef FEATURE_WLAN_LFR
1515#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1516 /* In case of reassoc requested by upper layer, look for exact match of bssid & channel;
1517 csr cache might have duplicates*/
1518 if ((pNeighborRoamInfo->uOsRequestedHandoff) &&
1519 ((VOS_FALSE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1520 pNeighborRoamInfo->handoffReqInfo.bssid,
1521 sizeof(tSirMacAddr)))||
1522 (pScanResult->BssDescriptor.channelId != pNeighborRoamInfo->handoffReqInfo.channel)))
1523
1524 {
1525 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1526 "SKIP-not a candidate AP for OS requested roam");
1527 continue;
1528 }
1529#endif
1530#endif
1531
Mukul Sharma20aa6582014-08-07 21:36:12 +05301532#ifdef FEATURE_WLAN_LFR
1533#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1534 if (pNeighborRoamInfo->isForcedInitialRoamTo5GH)
1535 {
1536 //Below check is required because scanning for forced initial roaming we have not
1537 //flush all the 2.4 GHz Channel, so it may possbile we may roam again to
1538 //2.4 Ghz ap only.
1539 if(GetRFBand(pScanResult->BssDescriptor.channelId) != SIR_BAND_5_GHZ)
1540 {
1541 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1542 "%s: Forced Roam to 5G Skip Non 5G Scan results ", __func__);
1543 continue;
1544 }
1545
Mukul Sharmad49b3d62014-09-02 01:45:32 +05301546 //rssi's are -ve value, so if abs of rssi is greater
1547 //means new ap is poor then currently connected ap.
1548 //Check it is only poor within nSelect5GHzMargin value.
1549 if (abs(pScanResult->BssDescriptor.rssi) > abs(CurrAPRssi) &&
1550 ((abs(pScanResult->BssDescriptor.rssi) - abs(CurrAPRssi))
1551 > pMac->roam.configParam.nSelect5GHzMargin)
1552 )
Mukul Sharma20aa6582014-08-07 21:36:12 +05301553 {
1554 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Mukul Sharmad49b3d62014-09-02 01:45:32 +05301555 "%s: Forced Roam to 5G Current AP rssi=%d new ap rssi=%d not good enough, nSelect5GHzMargin=%d", __func__,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301556 CurrAPRssi,
1557 (int)pScanResult->BssDescriptor.rssi * (-1),
Mukul Sharmad49b3d62014-09-02 01:45:32 +05301558 pMac->roam.configParam.nSelect5GHzMargin);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301559 continue;
1560 }
Mukul Sharmad49b3d62014-09-02 01:45:32 +05301561
Mukul Sharma20aa6582014-08-07 21:36:12 +05301562 }
1563#endif
1564#endif
1565
Jeff Johnson43971f52012-07-17 12:26:56 -07001566 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1567 * is disabled and we continue to roam without any check*/
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001568 if ((RoamRssiDiff > 0)
1569#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1570 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1571#endif
Mukul Sharmad88ee392014-12-19 16:52:53 +05301572 && ((eSME_ROAM_TRIGGER_SCAN != pNeighborRoamInfo->cfgRoamEn) &&
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05301573 (eSME_ROAM_TRIGGER_FAST_ROAM != pNeighborRoamInfo->cfgRoamEn)))
Jeff Johnson43971f52012-07-17 12:26:56 -07001574 {
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001575 /*
1576 * If RSSI is lower than the lookup threshold, then continue.
1577 */
1578 if (abs(pScanResult->BssDescriptor.rssi) >
1579 pNeighborRoamInfo->currentNeighborLookupThreshold)
1580 {
1581 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001582 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)",
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001583 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1584 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1585 continue;
1586 }
1587
Jeff Johnson43971f52012-07-17 12:26:56 -07001588 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1589 {
1590 /*Do not roam to an AP with worse RSSI than the current*/
1591 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001592 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001593 CurrAPRssi,
1594 (int)pScanResult->BssDescriptor.rssi * (-1) );
1595 continue;
1596 } else {
1597 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1598 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1599 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1600 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001601 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001602 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d", __func__,
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001603 CurrAPRssi,
1604 (int)pScanResult->BssDescriptor.rssi * (-1),
1605 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001606 continue;
1607 }
1608 else {
1609 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001610 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001611 CurrAPRssi,
1612 (int)pScanResult->BssDescriptor.rssi * (-1) );
1613 }
1614 }
1615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001616
1617#ifdef WLAN_FEATURE_VOWIFI_11R
1618 if (pNeighborRoamInfo->is11rAssoc)
1619 {
1620 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1621 {
1622 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1623 continue;
1624 }
1625 }
1626#endif /* WLAN_FEATURE_VOWIFI_11R */
1627
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001628#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001629#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1630 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001632#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001633 if (pNeighborRoamInfo->isESEAssoc)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001634 {
1635 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1636 {
1637 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1638 continue;
1639 }
1640 }
1641 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1642 (pScanResult->BssDescriptor.QBSSLoad_avail))
1643 {
1644 if (pNeighborRoamInfo->isVOAdmitted)
1645 {
1646 smsLog(pMac, LOG1, FL("New AP has %x BW available"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1647 smsLog(pMac, LOG1, FL("We need %x BW available"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
1648 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1649 {
1650 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08001651 "[INFOLOG]BSSID : "MAC_ADDRESS_STR" has no bandwidth ignoring..not adding to roam list",
1652 MAC_ADDR_ARRAY(pScanResult->BssDescriptor.bssId));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001653 continue;
1654 }
1655 }
1656 }
1657 else
1658 {
1659 smsLog(pMac, LOGE, FL("No QBss %x %x"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail, (unsigned int)pScanResult->BssDescriptor.QBSSLoad_present);
1660 if (pNeighborRoamInfo->isVOAdmitted)
1661 {
1662 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08001663 "[INFOLOG]BSSID : "MAC_ADDRESS_STR" has no QBSSLoad IE, ignoring..not adding to roam list",
1664 MAC_ADDR_ARRAY(pScanResult->BssDescriptor.bssId));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001665 continue;
1666 }
1667 }
1668#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001670#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001671#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001672
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001673#ifdef FEATURE_WLAN_LFR
1674 // If we are supporting legacy roaming, and
1675 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301676 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001677 {
1678 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1679 {
1680 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1681 continue;
1682 }
1683 }
1684#endif /* FEATURE_WLAN_LFR */
1685
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1687 * this result */
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001688 if ((pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1689#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1690 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1691#endif
1692 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 {
1694 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1695 continue;
1696 }
1697
1698 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1699 if (NULL == pBssInfo)
1700 {
1701 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1702 continue;
1703 }
1704
1705 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1706 if (pBssInfo->pBssDescription != NULL)
1707 {
1708 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1709 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1710 }
1711 else
1712 {
1713 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1714 vos_mem_free(pBssInfo);
1715 continue;
1716
1717 }
1718 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1719
1720 /* Just add to the end of the list as it is already sorted by RSSI */
1721 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001722
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001723#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05301724 if ((eSME_ROAM_TRIGGER_SCAN == pNeighborRoamInfo->cfgRoamEn) ||
1725 (eSME_ROAM_TRIGGER_FAST_ROAM == pNeighborRoamInfo->cfgRoamEn))
1726 {
1727 roamNow = eANI_BOOLEAN_FALSE;
1728 }
1729 else if ((abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) >= immediateRoamRssiDiff)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001730#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1731 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1732#endif
1733 )
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001734 {
1735 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsonce8ad512013-10-30 12:34:42 -07001736 "%s: [INFOLOG] potential candidate to roam immediately (diff=%ld, expected=%d)",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001737 __func__, abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)),
1738 immediateRoamRssiDiff);
1739 roamNow = eANI_BOOLEAN_TRUE;
1740 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001741#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1742 /* If we are here means, FW already found candidates to roam, so we are
1743 good to go with pre-auth */
1744 if(csrRoamIsRoamOffloadScanEnabled(pMac))
1745 {
1746 roamNow = eANI_BOOLEAN_TRUE;
1747 }
1748#endif
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001749#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 }
1751
1752 /* 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 */
1753 csrScanResultPurge(pMac, *pScanResultList);
1754
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001755 return roamNow;
Jeff Johnson295189b2012-06-20 16:38:30 -07001756}
1757
1758/* ---------------------------------------------------------------------------
1759
1760 \fn csrNeighborRoamHandleEmptyScanResult
1761
1762 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1763 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001764 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001766 1. Stop the neighbor scan timer.
1767 2a. If this is the first time we encountered empty scan, then
1768 re-register with TL with modified lookup threshold.
1769 2b. Else if this is the second time we encountered empty scan,
1770 then start neighbor scan results refresh timer (20s).
1771 2c. Else, nothing more to do.
1772 NOTE: In LFR, channels selected for scanning is dervied from
1773 the occuped channel list. Scan cycle following one which
1774 yielded empty results is split into two halves: (i) scan on
1775 channels in the occupied list, and (ii) scan on channels not
1776 in the occupied list. This helps converging faster (while
1777 looking for candidates in the occupied list first), and also,
1778 adds channels to the occupied channel list upon finding candidates
1779 matching SSID profile of interest.
1780
1781 uEmptyScanCount Comments
1782 eFirstEmptyScan Previous scan was done on channels in the
1783 occupied list and yielded potential candidates.
1784 This scan cycle was likely triggered through
1785 receipt of lookup DOWN notification event.
1786 eSecondEmptyScan Previous scan was done on channels in the
1787 occupied list and yielded no candidates. This scan
1788 cycle was triggered through RSSI notification
1789 with modified lookup threshold.
1790 eThirdEmptyScan Previous scan was done on channels NOT in
1791 the occupied list and yielded no candidates. This
1792 scan cycle was triggered immediately after scanning
1793 channels in the occupied list and no candidates
1794 were found.
1795 eFourthEmptyScan Previous scan was done on channels in the
1796 occupied list and yielded no candidates. This scan
1797 cycle was triggered upon expiry of
1798 neighborScanResultsRefreshPeriod (=20s).
1799 eFifthEmptyScan Previous scan was done on channels NOT in
1800 the occupied list and yielded no candidates. This
1801 scan cycle was triggered immediately after scanning
1802 channels in the occupied list and no candidates
1803 were found.
1804
1805 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001806
1807 \param pMac - The handle returned by macOpen.
1808
1809 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1810
1811---------------------------------------------------------------------------*/
1812static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1813{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001814 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1816 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001817#ifdef FEATURE_WLAN_LFR
1818 tANI_BOOLEAN performPeriodicScan =
1819 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod) ? TRUE : FALSE;
1820#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001821
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001822 /* Stop neighbor scan timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05301823 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001824 /*
1825 * Increase the neighbor lookup threshold by 3 dB
1826 * after every scan cycle. NOTE: uEmptyScanCount
1827 * would be either 1, 3 or 5 at the end of every
1828 * scan cycle.
1829 */
1830#ifdef FEATURE_WLAN_LFR
1831 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1832 {
1833 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1834 }
Srikant Kuppa327c52e2013-05-09 15:09:24 -07001835 if (((0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) ||
1836 (abs(pNeighborRoamInfo->lookupDOWNRssi) >
1837 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold))) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001838 ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1839 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan)))
1840 {
1841 /*
1842 * If the scan was triggered due to lookupDOWNRssi > reassoc threshold,
1843 * then it would be a contiguous scan on all valid non-DFS channels.
Srikant Kuppa327c52e2013-05-09 15:09:24 -07001844 * If channels are configured in INI, then only those channels need
1845 * to be scanned.
1846 * In either of these modes, there is no need to trigger an immediate
1847 * scan upon empty scan results for the second and fourth time (which
1848 * would be equivalent to scanning on channels in non-occupied list).
Srinivas Girigowdade697412013-02-14 16:31:48 -08001849 * Incrementing uEmptyScanCount will correspond to skipping this step.
1850 * NOTE: double increment of uEmptyScanCount corresponds to completion
1851 * of scans on all valid channels.
1852 */
1853 ++pNeighborRoamInfo->uEmptyScanCount;
1854 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Extra increment of empty scan count (=%d)"
1855 " in contiguous scan mode", pNeighborRoamInfo->uEmptyScanCount);
1856 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001857#endif
1858 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1859 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1860#ifdef FEATURE_WLAN_LFR
1861 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1862#endif
1863 )
1864 {
1865 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1866 }
1867
Jeff Johnson295189b2012-06-20 16:38:30 -07001868#ifdef WLAN_FEATURE_VOWIFI_11R
1869 /* Clear off the old neighbor report details */
1870 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1871#endif
1872
Srikant Kuppa866893f2012-12-27 17:28:14 -08001873 /* Transition to CONNECTED state */
1874 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1875
1876 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1877 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1878
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001879#ifdef FEATURE_WLAN_LFR
1880 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1881 {
1882#endif
1883 /* Empty scan results for the first time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001884 /* Re-register neighbor lookup DOWN threshold callback with TL */
1885 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1886 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1887 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1888
1889 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1890 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1891 WLANTL_HO_THRESHOLD_DOWN,
1892 csrNeighborRoamNeighborLookupDOWNCallback,
1893 VOS_MODULE_ID_SME, pMac);
1894
1895 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1896 {
1897 smsLog(pMac, LOGW,
1898 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001899 " with TL: Status = %d"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001900 }
1901#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08001902 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001903 }
1904 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1905 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1906 {
1907 /* Empty scan results for the second or fourth time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001908
1909 /* Immediately scan on channels in non-occupied list */
1910 csrNeighborRoamTransitToCFGChanScan(pMac);
1911 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001912 else if (pNeighborRoamInfo->uEmptyScanCount >= eThirdEmptyScan)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001913 {
1914 /* Empty scan results for the third time */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001915 if (performPeriodicScan)
1916 {
1917 smsLog(pMac, LOGE, FL("Performing periodic scan, uEmptyScanCount=%d"),
1918 pNeighborRoamInfo->uEmptyScanCount);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001919
Srinivas Girigowdade697412013-02-14 16:31:48 -08001920 /*
1921 * Set uEmptyScanCount to MAX so that we always enter this
1922 * condition on subsequent empty scan results
1923 */
1924 pNeighborRoamInfo->uEmptyScanCount = eMaxEmptyScan;
1925
1926 /* From here on, ONLY scan on channels in the occupied list */
1927 pNeighborRoamInfo->uScanMode = SPLIT_SCAN_OCCUPIED_LIST;
1928
1929 /* Start empty scan refresh timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05301930 if (VOS_STATUS_SUCCESS !=
1931 vos_timer_start(&pNeighborRoamInfo->emptyScanRefreshTimer,
1932 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001933 {
1934 smsLog(pMac, LOGE, FL("Empty scan refresh timer failed to start (%d)"),
1935 status);
1936 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1937 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07001938 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001939 vosStatus = VOS_STATUS_E_FAILURE;
1940 }
1941 else
1942 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07001943 smsLog(pMac, LOGE, FL("Empty scan refresh timer started (%d ms)"),
Srinivas Girigowdade697412013-02-14 16:31:48 -08001944 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod));
1945 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001946 }
Srikant Kuppa327c52e2013-05-09 15:09:24 -07001947 else if (eThirdEmptyScan == pNeighborRoamInfo->uEmptyScanCount)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001948 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001949 /* Start neighbor scan results refresh timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05301950 if (VOS_STATUS_SUCCESS !=
1951 vos_timer_start(&pNeighborRoamInfo->neighborResultsRefreshTimer,
1952 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001953 {
1954 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1955 status);
1956 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1957 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07001958 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001959 vosStatus = VOS_STATUS_E_FAILURE;
1960 }
1961 else
1962 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07001963 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%d ms)"),
Srinivas Girigowdade697412013-02-14 16:31:48 -08001964 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1965 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 }
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001968
Srinivas Girigowdade697412013-02-14 16:31:48 -08001969 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d scan mode=%d",
1970 pNeighborRoamInfo->uEmptyScanCount, pNeighborRoamInfo->uScanMode);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001971#endif
1972 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001973}
1974
Jeff Johnson295189b2012-06-20 16:38:30 -07001975
Srikant Kuppa866893f2012-12-27 17:28:14 -08001976static eHalStatus csrNeighborRoamProcessScanComplete (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07001977{
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 tCsrScanResultFilter scanFilter;
1980 tScanResultHandle scanResult;
1981 tANI_U32 tempVal = 0;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001982 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001983 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001984
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001985#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1987 should use the BSSID filter made out of neighbor reports */
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001988 if ((eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1989#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1990 && (!csrRoamIsRoamOffloadScanEnabled(pMac))
1991#endif
1992 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001994 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001995 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("11R or ESE Association: Prepare scan filter status with neighbor AP = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001996 tempVal = 1;
1997 }
1998 else
1999#endif
2000 {
Jeff Johnson43971f52012-07-17 12:26:56 -07002001 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002002 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("11R/ESE/Other Association: Prepare scan to find neighbor AP filter status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002004 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 {
2006 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
2007 return eHAL_STATUS_FAILURE;
2008 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002009 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302010 if (hstatus != eHAL_STATUS_SUCCESS)
2011 {
2012 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
2013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 /* Process the scan results and update roamable AP list */
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08002015 roamNow = csrNeighborRoamProcessScanResults(pMac, &scanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002016
2017 /* Free the scan filter */
2018 csrFreeScanFilter(pMac, &scanFilter);
2019
2020 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
2021
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002022#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2023 if(!csrRoamIsRoamOffloadScanEnabled(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002025#endif
2026 switch(pNeighborRoamInfo->neighborRoamState)
2027 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
2029 if (tempVal)
2030 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002031#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07002032 /*
2033 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002034 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07002035 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002036 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002037 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002038#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002039#ifdef WLAN_FEATURE_VOWIFI_11R
2040 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
2041 APs in the roamable AP list */
2042 if (pNeighborRoamInfo->is11rAssoc)
2043 {
2044 /* Valid APs are found after scan. Now we can initiate pre-authentication */
2045 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2046 }
2047 else
2048#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002049#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
2051 APs in the roamable AP list */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002052 if (pNeighborRoamInfo->isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 {
2054 /* Valid APs are found after scan. Now we can initiate pre-authentication */
2055 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2056 }
2057 else
2058#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002059#ifdef FEATURE_WLAN_LFR
2060 /* If LFR is enabled, then we can register the reassoc callback here as we have some
2061 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05302062 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002063 {
2064 /* Valid APs are found after scan. Now we can initiate pre-authentication */
2065 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2066 }
2067 else
2068#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 {
2070
2071 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
2072 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
2073 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
2074 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
2075 within certain duration */
2076
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302077// vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 }
2079 }
2080 else
2081 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05302082 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
2083 FL("No candidate found after scanning in state %s .. "),
2084 macTraceGetNeighbourRoamState(
2085 pNeighborRoamInfo->neighborRoamState));
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07002086 /* Handle it appropriately */
2087 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 }
2089 break;
2090#ifdef WLAN_FEATURE_VOWIFI_11R
2091 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2092 if (!tempVal)
2093 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05302094 smsLog(pMac, LOGE, FL("No candidate found after scanning"
2095 "in state %s .. "),
2096 macTraceGetNeighbourRoamState(
2097 pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
2099 csrNeighborRoamTransitToCFGChanScan(pMac);
2100 }
2101 break;
2102#endif /* WLAN_FEATURE_VOWIFI_11R */
2103 default:
2104 // Can come only in INIT state. Where in we are associated, we sent scan and user
2105 // in the meantime decides to disassoc, we will be in init state and still received call
2106 // back issued. Should not come here in any other state, printing just in case
2107 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05302108 FL("State %s"),
2109 macTraceGetNeighbourRoamState(
2110 pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002111
2112 // Lets just exit out silently.
2113 return eHAL_STATUS_SUCCESS;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002114 }
2115#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002118
2119 if (tempVal)
2120 {
2121 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2122
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08002123 if (roamNow)
2124 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002125#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2126 if(!csrRoamIsRoamOffloadScanEnabled(pMac))
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08002127 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002128#endif
2129 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
2130 FL("Immediate roam-deregister UP indication. RSSI = %d"),
2131 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
2132
2133 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
2134 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
2135 WLANTL_HO_THRESHOLD_UP,
2136 csrNeighborRoamNeighborLookupUPCallback,
2137 VOS_MODULE_ID_SME);
2138
2139 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2140 {
2141 smsLog(pMac, LOGW,
2142 FL("Couldn't deregister lookup UP callback with TL: Status = %d"), vosStatus);
2143 }
2144#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08002145 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002146#endif
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08002147
Mukul Sharmac353a5b2015-01-16 20:49:12 +05302148 hstatus = csrNeighborRoamTriggerHandoff(pMac,pNeighborRoamInfo);
2149 if(eHAL_STATUS_SUCCESS != hstatus)
2150 {
2151 smsLog(pMac, LOGE,
2152 FL("csrNeighborRoamTriggerHandoff fail status = %d"),
2153 hstatus);
2154 return eHAL_STATUS_FAILURE;
2155 }
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08002156 return eHAL_STATUS_SUCCESS;
2157 }
2158
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302159 hstatus = vos_timer_start(&pNeighborRoamInfo->neighborResultsRefreshTimer,
2160 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
2163 * that the callback getting called immediately and the timer would never be stopped when pre-auth is in progress */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302164 if( hstatus != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002166 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2168 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002169 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson43971f52012-07-17 12:26:56 -07002170 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002172
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2174 /* Register a reassoc Indication callback */
2175 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2176 WLANTL_HO_THRESHOLD_DOWN,
2177 csrNeighborRoamReassocIndCallback,
2178 VOS_MODULE_ID_SME, pMac);
2179
2180 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2181 {
2182 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002183 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 }
2185
2186 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002187#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
mukul sharma39718362014-05-24 21:59:52 +05302188 if (csrRoamIsRoamOffloadScanEnabled(pMac))
2189 {
2190 if (!tempVal || !roamNow)
2191 {
2192 if((eSME_ROAM_TRIGGER_SCAN == pNeighborRoamInfo->cfgRoamEn) ||
2193 (eSME_ROAM_TRIGGER_FAST_ROAM == pNeighborRoamInfo->cfgRoamEn))
2194 {
2195 //This is ioctl based roaming if we did not find any roamable
2196 //candidate then just log it.
2197 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2198 "tempVal = %u, roamNow = %d uOsRequestedHandoff = %d",
2199 tempVal, roamNow, pNeighborRoamInfo->uOsRequestedHandoff);
2200 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +05302201 else if (pNeighborRoamInfo->isForcedInitialRoamTo5GH)
2202 {
2203 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2204 "No 5G candidate found tempVal=%u, roamNow=%d",
2205 tempVal, roamNow);
2206 return eHAL_STATUS_FAILURE;
2207 }
mukul sharma39718362014-05-24 21:59:52 +05302208 else
2209 {
2210 if (pNeighborRoamInfo->uOsRequestedHandoff)
2211 {
2212 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START,
2213 REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
2214 pNeighborRoamInfo->uOsRequestedHandoff = 0;
2215 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +05302216
mukul sharma39718362014-05-24 21:59:52 +05302217 else
2218 {
Kapil Guptab3a981b2016-06-26 13:36:51 +05302219#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2220 if (pMac->PERroamCandidatesCnt == 0)
2221#endif
2222 {
2223 /* There is no candidate or We are not roaming Now.
2224 * Inform the FW to restart Roam Offload Scan */
2225 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_RESTART,
2226 REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
2227 }
mukul sharma39718362014-05-24 21:59:52 +05302228 }
2229 }
2230 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
2231 }
2232 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002233#endif
Srikant Kuppa866893f2012-12-27 17:28:14 -08002234 return eHAL_STATUS_SUCCESS;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002235}
2236
2237
2238/* ---------------------------------------------------------------------------
2239
2240 \fn csrNeighborRoamScanRequestCallback
2241
2242 \brief This function is the callback function registered in csrScanRequest() to
2243 indicate the completion of scan. If scan is completed for all the channels in
2244 the channel list, this function gets the scan result and starts the refresh results
2245 timer to avoid having stale results. If scan is not completed on all the channels,
2246 it restarts the neighbor scan timer which on expiry issues scan on the next
2247 channel
2248
2249 \param halHandle - The handle returned by macOpen.
2250 pContext - not used
2251 scanId - not used
2252 status - not used
2253
2254 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2255
2256---------------------------------------------------------------------------*/
2257static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
2258 tANI_U32 scanId, eCsrScanStatus status)
2259{
2260 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2261 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2262 tANI_U8 currentChanIndex;
2263 eHalStatus hstatus;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002264#ifdef FEATURE_WLAN_LFR
2265 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002266
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002267 if (NULL != pContext)
2268 {
2269 sessionId = *((tANI_U32*)pContext);
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002270
2271 if (!csrRoamIsStaMode(pMac, sessionId))
2272 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05302273 smsLog(pMac, LOGE, FL("Ignoring scan request callback on non-infra"
2274 "session %d in state %s"),
2275 sessionId, macTraceGetNeighbourRoamState(
2276 pNeighborRoamInfo->neighborRoamState));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002277 vos_mem_free(pContext);
2278 return eHAL_STATUS_SUCCESS;
2279 }
2280
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002281 if (!csrRoamIsFastRoamEnabled(pMac,sessionId))
2282 {
2283 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
2284 vos_mem_free(pContext);
2285 return eHAL_STATUS_SUCCESS;
2286 }
2287 }
2288#endif
Srikant Kuppa866893f2012-12-27 17:28:14 -08002289 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
2290
2291 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
2292 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
2293 {
2294 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002295 if (NULL != pContext)
2296 vos_mem_free(pContext);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002297 return eHAL_STATUS_SUCCESS;
2298 }
2299
2300 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
2301 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
2302
2303 /* Validate inputs */
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002304 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002305 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08002306 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
2307 }
2308 else
2309 {
2310 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002311 if (NULL != pContext)
2312 vos_mem_free(pContext);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002313 return eHAL_STATUS_SUCCESS;
2314 }
2315
2316 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
2317 {
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002318 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
Srikant Kuppa866893f2012-12-27 17:28:14 -08002319 just to get the results and perform PREAUTH */
2320 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
2321 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
2322 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
2323 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
2324
2325 hstatus = csrNeighborRoamProcessScanComplete(pMac);
2326
2327 if (eHAL_STATUS_SUCCESS != hstatus)
2328 {
2329 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002330 if (NULL != pContext)
2331 vos_mem_free(pContext);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002332 return eHAL_STATUS_FAILURE;
2333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 }
2335 else
2336 {
2337
2338 /* Restart the timer for the next scan sequence as scanning is not over */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302339 hstatus = vos_timer_start(&pNeighborRoamInfo->neighborScanTimer,
2340 pNeighborRoamInfo->cfgParams.neighborScanPeriod);
Jeff Johnson43971f52012-07-17 12:26:56 -07002341 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 {
2343 /* Timer start failed.. Should we ASSERT here??? */
2344 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
2345 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2346 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002347 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002348 if (NULL != pContext)
2349 vos_mem_free(pContext);
Jeff Johnson43971f52012-07-17 12:26:56 -07002350 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 }
2352 }
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002353
2354 if (NULL != pContext)
2355 vos_mem_free(pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 return eHAL_STATUS_SUCCESS;
2357}
2358
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002359#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2360/* ---------------------------------------------------------------------------
2361
2362 \fn csrNeighborRoamScanResultRequestCallback
2363
2364 \brief This function is the callback function registered in csrScanRequestLfrResult() to
2365 indicate the completion of scan. If scan is completed for all the channels in
2366 the channel list, this function gets the scan result and treats them as candidates
2367
2368 \param halHandle - The handle returned by macOpen.
2369 pContext - not used
2370 scanId - not used
2371 status - not used
2372
2373 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2374
2375---------------------------------------------------------------------------*/
2376static eHalStatus csrNeighborRoamScanResultRequestCallback(tHalHandle halHandle, void *pContext,
2377 tANI_U32 scanId, eCsrScanStatus status)
2378{
2379 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2380 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2381 eHalStatus hstatus;
2382
2383 smsLog(pMac, LOG2, FL("called "));
2384 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
2385
2386 /* we must be in connected state, if not ignore it */
2387 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
2388 {
2389 smsLog(pMac, LOGW, FL("Received in not CONNECTED state. Ignore it"));
2390 return eHAL_STATUS_SUCCESS;
2391 }
2392
2393 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
2394 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
2395
2396 hstatus = csrNeighborRoamProcessScanComplete(pMac);
2397
2398 if (eHAL_STATUS_SUCCESS != hstatus)
2399 {
2400 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
2401 return eHAL_STATUS_FAILURE;
2402 }
2403 return eHAL_STATUS_SUCCESS;
2404}
2405#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2406
Srikant Kuppa866893f2012-12-27 17:28:14 -08002407#ifdef FEATURE_WLAN_LFR
Mukul Sharma20aa6582014-08-07 21:36:12 +05302408static eHalStatus csrNeighborRoamForceRoamTo5GhScanCb(tHalHandle halHandle,
2409 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
2410{
2411 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2412 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2413 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
2414 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
2415
2416 if (NULL != pContext)
2417 {
2418 sessionId = *((tANI_U32*)pContext);
2419 if (!csrRoamIsFastRoamEnabled(pMac,sessionId))
2420 {
2421 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
2422 hstatus = eHAL_STATUS_FAILURE;
2423 goto end;
2424 }
2425 }
2426
2427 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
2428
Mukul Sharmac353a5b2015-01-16 20:49:12 +05302429 if (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN != pNeighborRoamInfo->neighborRoamState)
Mukul Sharma20aa6582014-08-07 21:36:12 +05302430 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +05302431 smsLog(pMac, LOGE, FL("Received in neighborRoamState %d . Ignore it"),
2432 pNeighborRoamInfo->neighborRoamState);
Mukul Sharma20aa6582014-08-07 21:36:12 +05302433 hstatus = eHAL_STATUS_FAILURE;
2434 goto end;
2435 }
2436
Mukul Sharmac353a5b2015-01-16 20:49:12 +05302437 //keep track of forced 5G scan & roam is due to Forced initial roam to 5GHz
2438 pNeighborRoamInfo->isForcedInitialRoamTo5GH = 1;
Mukul Sharma20aa6582014-08-07 21:36:12 +05302439
2440 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
2441 hstatus = csrNeighborRoamProcessScanComplete(pMac);
Mukul Sharmad49b3d62014-09-02 01:45:32 +05302442
Mukul Sharma20aa6582014-08-07 21:36:12 +05302443 if (eHAL_STATUS_SUCCESS != hstatus)
2444 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +05302445 smsLog(pMac, LOGE, FL("Force Roam To 5GhScanCb failed with status %d"),
2446 hstatus);
2447 pNeighborRoamInfo->isForcedInitialRoamTo5GH = 0;
2448 /*
2449 * Send RSO start because in case 5G roaming host have
2450 * not enabled at initial connection
2451 */
2452 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
2453 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
Mukul Sharma20aa6582014-08-07 21:36:12 +05302454 }
2455
2456 if (NULL != pContext)
2457 vos_mem_free(pContext);
2458 return hstatus;
2459
2460end:
2461 if (NULL != pContext)
2462 vos_mem_free(pContext);
Mukul Sharma20aa6582014-08-07 21:36:12 +05302463 return hstatus;
2464}
2465#endif
2466
2467#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002468static eHalStatus csrNeighborRoamContiguousScanRequestCallback(tHalHandle halHandle,
Srikant Kuppa866893f2012-12-27 17:28:14 -08002469 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
2470{
2471 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2472 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2473 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002474 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
2475
2476 if (NULL != pContext)
2477 {
2478 sessionId = *((tANI_U32*)pContext);
2479 if (!csrRoamIsFastRoamEnabled(pMac,sessionId))
2480 {
2481 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
2482 vos_mem_free(pContext);
2483 return eHAL_STATUS_SUCCESS;
2484 }
2485 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002486
2487 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002488
Srikant Kuppa866893f2012-12-27 17:28:14 -08002489 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
2490 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
2491 {
2492 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002493 if (NULL != pContext)
2494 vos_mem_free(pContext);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002495 return eHAL_STATUS_SUCCESS;
2496 }
2497
Srinivas Girigowdade697412013-02-14 16:31:48 -08002498 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
2499 {
2500 smsLog(pMac, LOGE, FL("Received in INIT state. Must have disconnected. Ignore it"));
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002501 if (NULL != pContext)
2502 vos_mem_free(pContext);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002503 return eHAL_STATUS_SUCCESS;
2504 }
2505
Srikant Kuppa866893f2012-12-27 17:28:14 -08002506 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
2507 hstatus = csrNeighborRoamProcessScanComplete(pMac);
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002508
Srikant Kuppa866893f2012-12-27 17:28:14 -08002509 if (eHAL_STATUS_SUCCESS != hstatus)
2510 {
2511 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
2512 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002513
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002514 if (NULL != pContext)
2515 vos_mem_free(pContext);
2516
Srikant Kuppa866893f2012-12-27 17:28:14 -08002517 return hstatus;
2518}
2519#endif
2520
Jeff Johnson295189b2012-06-20 16:38:30 -07002521/* ---------------------------------------------------------------------------
2522
2523 \fn csrNeighborRoamIssueBgScanRequest
2524
2525 \brief This function issues CSR scan request after populating all the BG scan params
2526 passed
2527
2528 \param pMac - The handle returned by macOpen.
2529 pBgScanParams - Params that need to be populated into csr Scan request
2530
2531 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2532
2533---------------------------------------------------------------------------*/
Srikant Kuppa866893f2012-12-27 17:28:14 -08002534eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac,
2535 tCsrBGScanRequest *pBgScanParams,
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002536 tANI_U32 sessionId,
Srikant Kuppa866893f2012-12-27 17:28:14 -08002537 csrScanCompleteCallback callbackfn)
Jeff Johnson295189b2012-06-20 16:38:30 -07002538{
2539 eHalStatus status = eHAL_STATUS_SUCCESS;
2540 tANI_U32 scanId;
2541 tCsrScanRequest scanReq;
2542 tANI_U8 channel;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002543 void * userData = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002544
Srikant Kuppa866893f2012-12-27 17:28:14 -08002545 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002546 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel = %d, ChanIndex = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08002547 pBgScanParams->ChannelInfo.ChannelList[0],
2548 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07002549
2550 //send down the scan req for 1 channel on the associated SSID
Kiet Lam64c1b492013-07-12 13:56:44 +05302551 vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 /* Fill in the SSID Info */
2553 scanReq.SSIDs.numOfSSIDs = 1;
2554 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
Kiet Lam64c1b492013-07-12 13:56:44 +05302555 if (NULL == scanReq.SSIDs.SSIDList)
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 {
2557 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002558 smsLog(pMac, LOGE, FL("Couldn't allocate memory for the SSID..Freeing memory allocated for Channel List"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 return eHAL_STATUS_FAILURE;
2560 }
2561 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
2562
2563 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
2564 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
2565 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
2566
2567 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002568 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
2569 {
2570 channel = pBgScanParams->ChannelInfo.ChannelList[0];
2571 scanReq.ChannelInfo.ChannelList = &channel;
2572 }
2573 else
2574 {
2575 scanReq.ChannelInfo.ChannelList = pBgScanParams->ChannelInfo.ChannelList;
2576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002577
2578 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2579 scanReq.scanType = eSIR_ACTIVE_SCAN;
2580 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
2581 scanReq.maxChnTime = pBgScanParams->maxChnTime;
2582 scanReq.minChnTime = pBgScanParams->minChnTime;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002583
2584 userData = vos_mem_malloc(sizeof(tANI_U32));
2585 if (NULL == userData)
2586 {
2587 smsLog(pMac, LOGE, FL("Failed to allocate memory for scan request"));
2588 vos_mem_free(scanReq.SSIDs.SSIDList);
2589 return eHAL_STATUS_FAILURE;
2590 }
2591 *((tANI_U32*)userData) = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002593 &scanId, callbackfn, (void *) userData);
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 if (eHAL_STATUS_SUCCESS != status)
2595 {
2596 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
2597 vos_mem_free(scanReq.SSIDs.SSIDList);
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002598 vos_mem_free(userData);
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 return status;
2600 }
2601 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
2602
2603 vos_mem_free(scanReq.SSIDs.SSIDList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002604 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Jeff Johnsonce8ad512013-10-30 12:34:42 -07002605 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %p, Actual index = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08002606 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
2607 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
2608
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 return status;
2610}
2611
Srikant Kuppa866893f2012-12-27 17:28:14 -08002612static void csrNeighborRoamFillNonChannelBgScanParams (tpAniSirGlobal pMac,
2613 tpCsrBGScanRequest bgScanParams)
2614{
2615 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2616 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
2617
2618 vos_mem_copy(bgScanParams->bssid, broadcastBssid, sizeof(tCsrBssid));
2619 bgScanParams->SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2620 vos_mem_copy(bgScanParams->SSID.ssId,
2621 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2622 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2623
2624 bgScanParams->minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
2625 bgScanParams->maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
2626}
2627
Jeff Johnson295189b2012-06-20 16:38:30 -07002628/* ---------------------------------------------------------------------------
2629
2630 \fn csrNeighborRoamPerformBgScan
2631
2632 \brief This function is invoked on every expiry of neighborScanTimer till all
2633 the channels in the channel list are scanned. It populates necessary
2634 parameters for BG scan and calls appropriate AP to invoke the CSR scan
2635 request
2636
2637 \param pMac - The handle returned by macOpen.
2638
2639 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2640
2641---------------------------------------------------------------------------*/
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002642eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002643{
2644 eHalStatus status = eHAL_STATUS_SUCCESS;
2645 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2646 tCsrBGScanRequest bgScanParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 tANI_U8 channel = 0;
2648
Abhishek Singh5c30c822014-04-07 15:15:40 +05302649 if ( pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList &&
2650 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels )
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07002652 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %p"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 }
2654 else
2655 {
2656 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
Jeff Johnson902c9832012-12-10 14:28:09 -08002657 // Go back and restart. Mostly timer start failure has occurred.
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 // When timer start is declared a failure, then we delete the list.
2659 // Should not happen now as we stop and then only start the scan timer.
2660 // still handle the unlikely case.
2661 csrNeighborRoamHandleEmptyScanResult(pMac);
2662 return status;
2663 }
James Zmuda9ea1edd2013-04-18 18:20:54 -07002664
2665 /* Validate the currentChanIndex value before using it to index the ChannelList array */
2666 if ( pNeighborRoamInfo->roamChannelInfo.currentChanIndex
2667 > pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
2668 {
2669 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Invalid channel index: %d"), pNeighborRoamInfo->roamChannelInfo.currentChanIndex);
2670 // Go back and restart.
2671 csrNeighborRoamHandleEmptyScanResult(pMac);
2672 return status;
2673 }
2674
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 /* Need to perform scan here before getting the list */
Srikant Kuppa866893f2012-12-27 17:28:14 -08002676
Kiet Lam64c1b492013-07-12 13:56:44 +05302677 vos_mem_set(&bgScanParams, sizeof(tCsrBGScanRequest), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002678
2679 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
2680 bgScanParams.ChannelInfo.numOfChannels = 1;
2681 bgScanParams.ChannelInfo.ChannelList = &channel;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302682
Srikant Kuppa866893f2012-12-27 17:28:14 -08002683 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002684
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302685 /* Update the passive scan time for DFS channel */
2686 if ((TRUE == CSR_IS_CHANNEL_DFS(channel)) &&
2687 (TRUE == pMac->roam.configParam.allowDFSChannelRoam))
2688 {
2689 bgScanParams.minChnTime = pMac->roam.configParam.nPassiveMinChnTime;
2690 bgScanParams.maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2691 }
2692
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002693 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
2694 sessionId, csrNeighborRoamScanRequestCallback);
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 if (eHAL_STATUS_SUCCESS != status)
2696 {
2697 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 }
2699
2700 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
2701 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
2702 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
2703 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302704 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
2706 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
2707 /* We have completed scanning all the channels */
2708 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2709 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
2710 and select the best AP in the list */
2711 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
2712 {
2713 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
2714 }
2715 }
2716
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08002717 if (eHAL_STATUS_SUCCESS != status)
2718 {
2719 /*
2720 * If the status is not success, we need to call the callback
2721 * routine so that the state machine does not get stuck.
2722 */
2723 csrNeighborRoamScanRequestCallback(pMac, NULL, 0, eCSR_SCAN_FAILURE);
2724 }
2725
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 return status;
2727}
2728
Srikant Kuppa866893f2012-12-27 17:28:14 -08002729#ifdef FEATURE_WLAN_LFR
Mukul Sharma20aa6582014-08-07 21:36:12 +05302730eHalStatus csrNeighborRoamScanForInitialForced5GRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
2731{
2732 eHalStatus status = eHAL_STATUS_SUCCESS;
2733 tCsrBGScanRequest bgScanParams;
2734 tANI_U8 numOfChannels = 0, i = 0;
2735 tANI_U8 tempChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2736 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2737 tANI_U8 tempNumOfChannels = 0;
2738
2739 vos_mem_set(&bgScanParams, sizeof(tCsrBGScanRequest), 0);
2740 /* Contiguously scan all channels from valid list */
2741 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
2742 tempNumOfChannels = sizeof(pMac->roam.validChannelList);
2743
2744 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2745 (tANI_U8 *)pMac->roam.validChannelList,
2746 (tANI_U32 *) &tempNumOfChannels)))
2747 {
2748 //Make sure we are scanning only for 5Ghz AP only
2749 //Filetring out the 5GHZ based AP.from valid channel list
2750 csrNeighborRoamChannelsFilterByBand(
2751 pMac,
2752 pMac->roam.validChannelList,
2753 tempNumOfChannels,
2754 tempChannelList,
2755 &tempNumOfChannels,
2756 SIR_BAND_5_GHZ
2757 );
2758 for (i = 0; (i < tempNumOfChannels &&(i < WNI_CFG_VALID_CHANNEL_LIST_LEN)); i++)
2759 {
2760 /* DFS channel will be added in the list only when the
2761 DFS Roaming scan flag is enabled*/
2762 if (CSR_IS_CHANNEL_DFS(tempChannelList[i]))
2763 {
2764 if (pMac->roam.configParam.allowDFSChannelRoam == TRUE)
2765 {
2766 channelList[numOfChannels++] = tempChannelList[i];
2767 }
2768 }
2769 else
2770 {
2771 channelList[numOfChannels++] = tempChannelList[i];
2772 }
2773 }
2774 }
2775 else
2776 {
2777 smsLog(pMac, LOGW, FL("csrGetCfgValidChannels got failed "));
2778 return eHAL_STATUS_FAILURE;
2779 }
2780
2781 if(numOfChannels == 0)
2782 {
2783 smsLog(pMac, LOGE,
2784 FL(" No valid 5Ghz channel present so skipping Initial Forced 5Gh roaming"));
2785 return VOS_STATUS_E_EMPTY;
2786 }
2787 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2788 {
2789 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2790 }
2791
2792 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
2793 bgScanParams.ChannelInfo.ChannelList = channelList;
2794 for (i = 0; i < numOfChannels; i++)
2795 {
2796 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d",
2797 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
2798 }
2799 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
2800
2801 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
2802 sessionId, csrNeighborRoamForceRoamTo5GhScanCb);
2803
2804 if (eHAL_STATUS_SUCCESS != status)
2805 {
2806 smsLog(pMac, LOGE, FL("Forced intial roam to 5Gh request failed: Status = %d"), status);
Mukul Sharma1fa759f2015-01-02 17:12:44 +05302807 }
Mukul Sharma20aa6582014-08-07 21:36:12 +05302808 return status;
2809}
2810#endif
2811
2812#ifdef FEATURE_WLAN_LFR
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002813eHalStatus csrNeighborRoamPerformContiguousBgScan(tpAniSirGlobal pMac, tANI_U32 sessionId)
Srikant Kuppa866893f2012-12-27 17:28:14 -08002814{
2815 eHalStatus status = eHAL_STATUS_SUCCESS;
2816 tCsrBGScanRequest bgScanParams;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002817 tANI_U8 numOfChannels = 0, i = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002818 tANI_U8 *channelList = NULL;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002819 tANI_U8 *pInChannelList = NULL;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002820 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Srikant Kuppa866893f2012-12-27 17:28:14 -08002821
Kiet Lam64c1b492013-07-12 13:56:44 +05302822 vos_mem_set(&bgScanParams, sizeof(tCsrBGScanRequest), 0);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002823
2824 /* Contiguously scan all channels from valid list */
2825 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002826
Srinivas Girigowda56076852013-08-20 14:00:50 -07002827 numOfChannels = sizeof(pMac->roam.validChannelList);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002828
Srinivas Girigowda56076852013-08-20 14:00:50 -07002829 if(!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2830 (tANI_U8 *)pMac->roam.validChannelList,
2831 (tANI_U32 *) &numOfChannels)))
2832 {
2833 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
2834 return eHAL_STATUS_FAILURE;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002835 }
Srinivas Girigowda56076852013-08-20 14:00:50 -07002836 pInChannelList = pMac->roam.validChannelList;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002837
2838 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
2839 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05302840 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002841 pMac,
2842 pInChannelList,
2843 numOfChannels,
2844 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05302845 &numOfChannels,
2846 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002847 pInChannelList = tmpChannelList;
2848 }
2849
Kiet Lam64c1b492013-07-12 13:56:44 +05302850 channelList = vos_mem_malloc(numOfChannels);
2851 if ( NULL == channelList )
Srikant Kuppa866893f2012-12-27 17:28:14 -08002852 {
2853 smsLog(pMac, LOGE, FL("could not allocate memory for channelList"));
2854 return eHAL_STATUS_FAILURE;
2855 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002856 vos_mem_copy(channelList, (tANI_U8 *)pInChannelList,
Srikant Kuppa866893f2012-12-27 17:28:14 -08002857 numOfChannels * sizeof(tANI_U8));
2858
2859 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
2860 bgScanParams.ChannelInfo.ChannelList = channelList;
2861 for (i = 0; i < numOfChannels; i++)
2862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002863 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d",
Srikant Kuppa866893f2012-12-27 17:28:14 -08002864 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
2865 }
2866 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
2867
2868 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002869 sessionId, csrNeighborRoamContiguousScanRequestCallback);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002870
Kiet Lam64c1b492013-07-12 13:56:44 +05302871 vos_mem_free(channelList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002872
2873 if (eHAL_STATUS_SUCCESS != status)
2874 {
2875 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
2876 }
2877
2878 return status;
2879}
2880#endif
2881
Jeff Johnson295189b2012-06-20 16:38:30 -07002882/* ---------------------------------------------------------------------------
2883
2884 \fn csrNeighborRoamNeighborScanTimerCallback
2885
2886 \brief This function is the neighbor scan timer callback function. It invokes
2887 the BG scan request based on the current and previous states
2888
2889 \param pv - CSR timer context info which includes pMac and session ID
2890
2891 \return VOID
2892
2893---------------------------------------------------------------------------*/
2894void csrNeighborRoamNeighborScanTimerCallback(void *pv)
2895{
Mukul Sharmad177bd52015-01-05 21:03:38 +05302896 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
2897 tpCsrNeighborRoamControlInfo pNeighborRoamInfo;
2898 if(!pMac)
2899 {
2900 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("pMac is Null"));
2901 return;
2902 }
2903 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002904
2905 // check if bg scan is on going, no need to send down the new params if true
2906 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
2907 {
2908 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002909 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 return;
2911 }
2912
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 switch (pNeighborRoamInfo->neighborRoamState)
2914 {
2915#ifdef WLAN_FEATURE_VOWIFI_11R
2916 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2917 switch(pNeighborRoamInfo->prevNeighborRoamState)
2918 {
2919 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
Mukul Sharmad177bd52015-01-05 21:03:38 +05302920 csrNeighborRoamPerformBgScan(pMac, pNeighborRoamInfo->csrSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 break;
2922 default:
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05302923 smsLog(pMac, LOGE, FL("Neighbor scan callback received in"
2924 "state %s, prev state = %s"),
2925 macTraceGetNeighbourRoamState(
2926 pNeighborRoamInfo->neighborRoamState),
2927 macTraceGetNeighbourRoamState(
2928 pNeighborRoamInfo->prevNeighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 break;
2930 }
2931 break;
2932#endif /* WLAN_FEATURE_VOWIFI_11R */
2933 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
Mukul Sharmad177bd52015-01-05 21:03:38 +05302934 csrNeighborRoamPerformBgScan(pMac, pNeighborRoamInfo->csrSessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 break;
2936 default:
2937 break;
2938 }
2939 return;
2940}
2941
Srinivas Girigowdade697412013-02-14 16:31:48 -08002942void csrNeighborRoamEmptyScanRefreshTimerCallback(void *context)
2943{
Mukul Sharmad177bd52015-01-05 21:03:38 +05302944 tpAniSirGlobal pMac = PMAC_STRUCT( context );
Srinivas Girigowdade697412013-02-14 16:31:48 -08002945 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mukul Sharmad177bd52015-01-05 21:03:38 +05302946 tpCsrNeighborRoamControlInfo pNeighborRoamInfo;
2947 if(!pMac)
2948 {
2949 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("pMac is Null"));
2950 return;
2951 }
2952 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002953
2954 /* Reset all the variables just as no scan had happened before */
2955 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2956
2957#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2958 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2959 {
2960 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2961 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2962 if (VOS_STATUS_SUCCESS != vosStatus)
2963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002964 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002965 return;
2966 }
2967 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2968 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2969 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2970 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2971 }
2972 else
2973#endif
2974 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002975 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or ESE Association:empty scan refresh timer expired"));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002976 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2977 if (VOS_STATUS_SUCCESS != vosStatus)
2978 {
2979 return;
2980 }
2981 }
2982 return;
2983}
2984
Jeff Johnson295189b2012-06-20 16:38:30 -07002985/* ---------------------------------------------------------------------------
2986
2987 \fn csrNeighborRoamResultsRefreshTimerCallback
2988
2989 \brief This function is the timer callback function for results refresh timer.
2990 When this is invoked, it is as good as down event received from TL. So,
2991 clear off the roamable AP list and start the scan procedure based on 11R
2992 or non-11R association
2993
2994 \param context - CSR timer context info which includes pMac and session ID
2995
2996 \return VOID
2997
2998---------------------------------------------------------------------------*/
2999void csrNeighborRoamResultsRefreshTimerCallback(void *context)
3000{
Mukul Sharmad177bd52015-01-05 21:03:38 +05303001 tpAniSirGlobal pMac = PMAC_STRUCT( context );
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mukul Sharmad177bd52015-01-05 21:03:38 +05303003 tpCsrNeighborRoamControlInfo pNeighborRoamInfo;
3004
3005 if(!pMac)
3006 {
3007 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("pMac is Null"));
3008 return;
3009 }
3010 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3011
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
3013
3014 /* Deregister reassoc callback. Ignore return status */
3015 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
3016 WLANTL_HO_THRESHOLD_DOWN,
3017 csrNeighborRoamReassocIndCallback,
3018 VOS_MODULE_ID_SME);
3019
3020 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3021 {
3022 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003023 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 }
3025
3026 /* Reset all the variables just as no scan had happened before */
3027 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3028
3029#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
3030 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
3031 {
3032 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
3033 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
3034 if (VOS_STATUS_SUCCESS != vosStatus)
3035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003036 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 return;
3038 }
3039 /* Increment the neighbor report retry count after sending the neighbor request successfully */
3040 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
3041 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
3042 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
3043 }
3044 else
3045#endif
3046 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003047 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or ESE Association:results refresh timer expired"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
3049 if (VOS_STATUS_SUCCESS != vosStatus)
3050 {
3051 return;
3052 }
3053 }
3054 return;
3055}
3056
Mukul Sharma20aa6582014-08-07 21:36:12 +05303057/* ---------------------------------------------------------------------------
3058
3059 \fn csrForcedInitialRoamTo5GHTimerCallback
3060
3061 \brief This function is the timer callback function for triggering
3062 roaming to 5GHz after the initial association.
3063
3064 \param context - CSR timer context info which includes pMac and session ID
3065
3066 \return VOID
3067
3068---------------------------------------------------------------------------*/
3069
3070void csrForcedInitialRoamTo5GHTimerCallback(void *context)
3071{
Mukul Sharmad177bd52015-01-05 21:03:38 +05303072 tpAniSirGlobal pMac = PMAC_STRUCT( context );
Mukul Sharma20aa6582014-08-07 21:36:12 +05303073 eHalStatus status = eHAL_STATUS_SUCCESS;
Mukul Sharmad177bd52015-01-05 21:03:38 +05303074 tpCsrNeighborRoamControlInfo pNeighborRoamInfo;
3075 if(!pMac)
3076 {
3077 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("pMac is Null"));
3078 return;
3079 }
3080 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Mukul Sharma20aa6582014-08-07 21:36:12 +05303081
3082 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("forcedInitialRoamTo5GHTimer timer expired"));
3083
3084 //we don't need to run this timer any more
3085 vos_timer_stop(&pNeighborRoamInfo->forcedInitialRoamTo5GHTimer);
3086
3087 //we must be in connected state, if not ignore it
3088 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
3089 {
3090 smsLog(pMac, LOGE, FL("Received in not CONNECTED state. Ignore it"));
Mukul Sharma5b2ff502014-11-06 14:43:50 +05303091 return;
Mukul Sharma20aa6582014-08-07 21:36:12 +05303092 }
3093
3094 //it may possible user reconnected / DUT roamed to other band ap btw
3095 //timer started and timer callback hit.
3096 if(GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel) == SIR_BAND_5_GHZ)
3097 {
3098 smsLog(pMac, LOGE,
3099 FL("DUT is already connected to 5GH ap, so no need to trigger forced roam."));
Mukul Sharma5b2ff502014-11-06 14:43:50 +05303100 return;
Mukul Sharma20aa6582014-08-07 21:36:12 +05303101 }
3102
Deepthi Gowri4480a3f2016-05-18 19:30:17 +05303103 pNeighborRoamInfo->scanRequestTimeStamp = vos_timer_get_system_time();
Mukul Sharmac353a5b2015-01-16 20:49:12 +05303104 /*
3105 * We are about to start a fresh scan cycle for all valid channles for 5Ghz
3106 * purge non-P2P results from the past for 5Ghz band
3107 */
3108 csrScanFlushSelectiveResultForBand(pMac, VOS_FALSE, SIR_BAND_5_GHZ);
3109 status = csrNeighborRoamScanForInitialForced5GRoaming(
3110 pMac, pNeighborRoamInfo->csrSessionId);
3111 if(status != eHAL_STATUS_SUCCESS)
Mukul Sharma20aa6582014-08-07 21:36:12 +05303112 {
3113 smsLog(pMac, LOGE,
Mukul Sharmac353a5b2015-01-16 20:49:12 +05303114 FL("csrNeighborRoamScanForInitialForced5GRoaming failed status=%d"), status);
3115 //Send RSO start because in case 5G roaming host have not enabled at initial connection
3116 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
3117 return;
Mukul Sharma20aa6582014-08-07 21:36:12 +05303118 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +05303119
3120 /* Transition to CFG_CHAN_LIST_SCAN */
3121 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
Mukul Sharma20aa6582014-08-07 21:36:12 +05303122}
3123
Jeff Johnson295189b2012-06-20 16:38:30 -07003124#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
3125/* ---------------------------------------------------------------------------
3126
3127 \fn csrNeighborRoamIssueNeighborRptRequest
3128
3129 \brief This function is invoked when TL issues a down event and the current assoc
3130 is a 11R association. It invokes SME RRM API to issue the neighbor request to
3131 the currently associated AP with the current SSID
3132
3133 \param pMac - The handle returned by macOpen.
3134
3135 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3136
3137---------------------------------------------------------------------------*/
3138VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
3139{
3140 tRrmNeighborRspCallbackInfo callbackInfo;
3141 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3142 tRrmNeighborReq neighborReq;
3143
3144
3145 neighborReq.no_ssid = 0;
3146
3147 /* Fill in the SSID */
3148 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
3149 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
3150 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
3151
3152 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
3153 callbackInfo.neighborRspCallbackContext = pMac;
3154 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
3155
3156 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
3157}
3158
3159/* ---------------------------------------------------------------------------
3160
Mukul Sharma20aa6582014-08-07 21:36:12 +05303161 \fn csrNeighborRoamChannelsFilterByBand
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003162
3163 \brief This function is used to filter out the channels
Mukul Sharma20aa6582014-08-07 21:36:12 +05303164 based on the Band given as input
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003165
3166 \param pMac - The handle returned by macOpen.
3167 \param pInputChannelList - The input channel list
3168 \param inputNumOfChannels - The number of channels in input channel list
3169 \param pOutputChannelList - The output channel list
3170 \param outputNumOfChannels - The number of channels in output channel list
3171 \param pMergedOutputNumOfChannels - The final number of channels in the output channel list.
Mukul Sharma20aa6582014-08-07 21:36:12 +05303172 \param band - The band which will be get compared with the input channel list band
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003173
3174 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3175
3176---------------------------------------------------------------------------*/
3177
Mukul Sharma20aa6582014-08-07 21:36:12 +05303178VOS_STATUS csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003179 tpAniSirGlobal pMac,
3180 tANI_U8* pInputChannelList,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003181 tANI_U8 inputNumOfChannels,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003182 tANI_U8* pOutputChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05303183 tANI_U8* pMergedOutputNumOfChannels,
3184 tSirRFBand band
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003185 )
3186{
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003187 tANI_U8 i = 0;
3188 tANI_U8 numChannels = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05303189
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003190 // Check for NULL pointer
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303191 if (!pInputChannelList) return VOS_STATUS_E_INVAL;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003192
3193 // Check for NULL pointer
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303194 if (!pOutputChannelList) return VOS_STATUS_E_INVAL;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003195
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303196 if (inputNumOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3197 {
3198 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3199 "%s: Wrong Number of Input Channels %d",
3200 __func__, inputNumOfChannels);
3201 return VOS_STATUS_E_INVAL;
3202 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003203 for (i = 0; i < inputNumOfChannels; i++)
3204 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05303205 if (band == GetRFBand(pInputChannelList[i]))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003206 {
3207 pOutputChannelList[numChannels] = pInputChannelList[i];
3208 numChannels++;
3209 }
3210 }
3211
3212 // Return final number of channels
3213 *pMergedOutputNumOfChannels = numChannels;
3214
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303215 return VOS_STATUS_SUCCESS;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003216}
3217
3218/* ---------------------------------------------------------------------------
3219
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003220 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003221
3222 \brief This function is used to merge two channel list.
3223 NB: If called with outputNumOfChannels == 0, this routines
3224 simply copies the input channel list to the output channel list.
3225
3226 \param pMac - The handle returned by macOpen.
3227 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
3228 \param inputNumOfChannels - The number of additional channels.
3229 \param pOutputChannelList - The place to put the "merged" channel list.
3230 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
3231 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
3232
3233 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3234
3235---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003236VOS_STATUS csrNeighborRoamMergeChannelLists(
3237 tpAniSirGlobal pMac,
3238 tANI_U8 *pInputChannelList,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003239 tANI_U8 inputNumOfChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003240 tANI_U8 *pOutputChannelList,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003241 tANI_U8 outputNumOfChannels,
3242 tANI_U8 *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003243 )
3244{
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003245 tANI_U8 i = 0;
3246 tANI_U8 j = 0;
3247 tANI_U8 numChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003248
3249 // Check for NULL pointer
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303250 if (!pInputChannelList) return VOS_STATUS_E_INVAL;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003251
3252 // Check for NULL pointer
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303253 if (!pOutputChannelList) return VOS_STATUS_E_INVAL;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003254
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303255 if (inputNumOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3256 {
3257 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3258 "%s: Wrong Number of Input Channels %d",
3259 __func__, inputNumOfChannels);
3260 return VOS_STATUS_E_INVAL;
3261 }
Kaushik, Sushantc31ea482014-05-03 13:37:26 +05303262 if (outputNumOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3263 {
3264 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3265 "%s: Wrong Number of Output Channels %d",
3266 __func__, inputNumOfChannels);
3267 return VOS_STATUS_E_INVAL;
3268 }
3269
3270 /* Add the "new" channels in the input list to the end of the output list.
3271 Check added in for loop to make sure outputlist doesn't exceeds valid
3272 channel list length. */
3273 for (i = 0; (i < inputNumOfChannels) && (numChannels < WNI_CFG_VALID_CHANNEL_LIST_LEN); i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003274 {
3275 for (j = 0; j < outputNumOfChannels; j++)
3276 {
3277 if (pInputChannelList[i] == pOutputChannelList[j])
3278 break;
3279 }
3280 if (j == outputNumOfChannels)
3281 {
3282 if (pInputChannelList[i])
3283 {
Madan Mohan Koyyalamudif5c368b2012-12-06 13:10:13 -08003284 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003285 "%s: [INFOLOG] Adding extra %d to Neighbor channel list", __func__,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003286 pInputChannelList[i]);
3287 pOutputChannelList[numChannels] = pInputChannelList[i];
3288 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003289 }
3290 }
3291 }
3292
3293 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003294 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003295
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303296 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003297}
3298
3299/* ---------------------------------------------------------------------------
3300
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 \fn csrNeighborRoamCreateChanListFromNeighborReport
3302
3303 \brief This function is invoked when neighbor report is received for the
3304 neighbor request. Based on the channels present in the neighbor report,
3305 it generates channel list which will be used in REPORT_SCAN state to
3306 scan for these neighbor APs
3307
3308 \param pMac - The handle returned by macOpen.
3309
3310 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3311
3312---------------------------------------------------------------------------*/
3313VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
3314{
Abhishek Singh8f1a5b32014-04-10 14:37:52 +05303315 tpRrmNeighborReportDesc pNeighborBssDesc;
3316 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3317 tANI_U8 numChannels = 0;
3318 tANI_U8 i = 0;
3319 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
3320 tANI_U8 mergedOutputNumOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003321
3322 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
3323 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
3324
3325 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
3326
3327 while (pNeighborBssDesc)
3328 {
3329 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
3330
3331 /* Update the neighbor BSS Info in the 11r FT Roam Info */
3332 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
3333 pNeighborBssDesc->pNeighborBssDescription->channel;
3334 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
3335 (tANI_U8)pNeighborBssDesc->roamScore;
3336 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
3337 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
3338 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
3339
3340 /* Saving the channel list non-redundantly */
Abhishek Singh8f1a5b32014-04-10 14:37:52 +05303341 for (i = 0; (i < numChannels && i < MAX_BSS_IN_NEIGHBOR_RPT); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 {
Abhishek Singh8f1a5b32014-04-10 14:37:52 +05303343 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
3344 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 }
Abhishek Singh8f1a5b32014-04-10 14:37:52 +05303346
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 if (i == numChannels)
3348 {
3349 if (pNeighborBssDesc->pNeighborBssDescription->channel)
3350 {
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003351 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3352 {
3353 // Make sure to add only if its the same band
3354 if (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
3355 GetRFBand(pNeighborBssDesc->pNeighborBssDescription->channel))
3356 {
3357 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3358 "%s: [INFOLOG] Adding %d to Neighbor channel list (Same band)\n", __func__,
3359 pNeighborBssDesc->pNeighborBssDescription->channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
3361 numChannels++;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003362 }
3363 }
3364 else
3365 {
3366 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3367 "%s: [INFOLOG] Adding %d to Neighbor channel list\n", __func__,
3368 pNeighborBssDesc->pNeighborBssDescription->channel);
3369 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
3370 numChannels++;
3371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 }
3373 }
3374
3375 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
3376 }
3377
3378 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
3379 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3381 }
3382
3383 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07003384 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 /* Store the obtained channel list to the Neighbor Control data structure */
3386 if (numChannels)
3387 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
3388 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
3389 {
3390 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
3391 return VOS_STATUS_E_RESOURCES;
3392 }
3393
3394 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
3395 channelList, (numChannels) * sizeof(tANI_U8));
3396 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07003397 /*
3398 * Create a Union of occupied channel list learnt by the DUT along with the Neighbor
3399 * report Channels. This increases the chances of the DUT to get a candidate AP while
3400 * roaming even if the Neighbor Report is not able to provide sufficient information.
3401 * */
3402 if (pMac->scan.occupiedChannels.numChannels)
3403 {
3404 csrNeighborRoamMergeChannelLists(pMac,
3405 &pMac->scan.occupiedChannels.channelList[0],
3406 pMac->scan.occupiedChannels.numChannels,
3407 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0],
3408 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
3409 &mergedOutputNumOfChannels);
3410 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels =
3411 mergedOutputNumOfChannels;
3412
3413 }
3414 /*Indicate the firmware about the update only if any new channels are added.
3415 * Otherwise, the firmware would already be knowing the non-IAPPneighborlist
3416 * channels. There is no need to update.*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 if (numChannels)
3418 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05303419 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected"
3420 "in state %s."),
3421 macTraceGetNeighbourRoamState(
3422 pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003424#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07003425 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003426 {
3427 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
3428 }
3429#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 }
3431 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
3432 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
3433
3434 return VOS_STATUS_SUCCESS;
3435}
3436
3437/* ---------------------------------------------------------------------------
3438
3439 \fn csrNeighborRoamRRMNeighborReportResult
3440
3441 \brief This function is the neighbor report callback that will be invoked by
3442 SME RRM on receiving a neighbor report or of neighbor report is not
3443 received after timeout. On receiving a valid report, it generates a
3444 channel list from the neighbor report and starts the
3445 neighbor scan timer
3446
3447 \param context - The handle returned by macOpen.
3448 vosStatus - Status of the callback(SUCCESS/FAILURE)
3449
3450 \return VOID
3451
3452---------------------------------------------------------------------------*/
3453void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
3454{
3455 tpAniSirGlobal pMac = PMAC_STRUCT(context);
3456 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3457 eHalStatus status = eHAL_STATUS_SUCCESS;
3458
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003459 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 switch (pNeighborRoamInfo->neighborRoamState)
3461 {
3462 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
3463 /* Reset the report pending variable */
3464 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
3465 if (VOS_STATUS_SUCCESS == vosStatus)
3466 {
3467 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
3468 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
3469 if (VOS_STATUS_SUCCESS == vosStatus)
3470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003471 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 }
3473
3474 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
Deepthi Gowri4480a3f2016-05-18 19:30:17 +05303475 pNeighborRoamInfo->scanRequestTimeStamp =
3476 vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07003477
3478 /* Now ready for neighbor scan based on the channel list created */
3479 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
3480 what palTimerStart expects */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05303481 status = vos_timer_start(&pNeighborRoamInfo->neighborScanTimer,
3482 pNeighborRoamInfo->cfgParams.neighborScanPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 if (eHAL_STATUS_SUCCESS != status)
3484 {
3485 /* Timer start failed.. Should we ASSERT here??? */
3486 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
3487 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3488 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07003489 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 return;
3491 }
3492 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3493 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
3494 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
3495 }
3496 else
3497 {
3498 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
3499 reach the maxNeighborRetries or receiving a successful neighbor response */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003500 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
3502 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
3503 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
3504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003505 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
3507 if (VOS_STATUS_SUCCESS != vosStatus)
3508 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003509 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d "), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 return;
3511 }
3512 /* We transitioned to different state now. Reset the Neighbor report retry count */
3513 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3514 }
3515 else
3516 {
3517 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
3518 if (VOS_STATUS_SUCCESS != vosStatus)
3519 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003520 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 return;
3522 }
3523 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
3524 /* Increment the neighbor report retry count after sending the neighbor request successfully */
3525 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
3526 }
3527 }
3528 break;
3529 default:
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05303530 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in"
3531 "state %s, Ignoring.."),
3532 macTraceGetNeighbourRoamState(
3533 pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 break;
3535 }
3536 return;
3537}
3538#endif /* WLAN_FEATURE_VOWIFI_11R */
3539
3540
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003541#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003542tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003543 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003544 tCsrRoamConnectedProfile *pCurProfile,
3545 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003546 tDot11fBeaconIEs *pIes)
3547{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003548 tCsrAuthList authType;
3549 tCsrEncryptionList uCEncryptionType;
3550 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003551 tANI_BOOLEAN fMatch = FALSE;
3552
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003553 authType.numEntries = 1;
3554 authType.authType[0] = pCurProfile->AuthType;
3555 uCEncryptionType.numEntries = 1;
3556 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
3557 mCEncryptionType.numEntries = 1;
3558 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003559
3560 if( pIes )
3561 {
3562 if(pIes->SSID.present)
3563 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003564 fMatch = csrIsSsidMatch( pMac,
3565 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
3566 pIes->SSID.ssid, pIes->SSID.num_ssid,
3567 eANI_BOOLEAN_TRUE );
3568 if(TRUE == fMatch)
3569 {
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303570 /*
3571 * for now we are sending NULL for all PMF related filter
3572 * parameters during roam to the neighbor AP because
3573 * so far 80211W spec doesn't specify anything about
3574 * roaming scenario.
3575 *
3576 * Once roaming scenario is defined, we should re-visit
3577 * this section and remove this comment.
3578 */
3579 fMatch = csrIsSecurityMatch(pMac, &authType, &uCEncryptionType,
3580 &mCEncryptionType,
3581 NULL, NULL, NULL,
3582 pBssDesc, pIes, NULL, NULL, NULL);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003583 return (fMatch);
3584 }
3585 else
3586 {
3587 return (fMatch);
3588 }
3589
3590 }
3591 else
3592 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003593 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003594 }
3595 }
3596 else
3597 {
3598 return FALSE; // Again, treat missing pIes as a non-match.
3599 }
3600}
3601
3602tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
3603 tpAniSirGlobal pMac)
3604{
3605 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3606 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
3607 tCsrRoamConnectedProfile *pCurrProfile = NULL;
3608 tCsrRoamConnectedProfile *pPrevProfile = NULL;
3609 tDot11fBeaconIEs *pIes = NULL;
3610 tSirBssDescription *pBssDesc = NULL;
3611 tANI_BOOLEAN fNew = TRUE;
3612
3613 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
3614 {
3615 return (fNew);
3616 }
3617
3618 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
3619 if( !pCurrProfile )
3620 {
3621 return (fNew);
3622}
3623
3624 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
3625 if( !pPrevProfile )
3626 {
3627 return (fNew);
3628 }
3629
3630 pBssDesc = pPrevProfile->pBssDesc;
3631 if (pBssDesc)
3632 {
3633 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
3634 pBssDesc, &pIes)) &&
3635 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
3636 {
3637 fNew = FALSE;
3638 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303639 if (pIes)
3640 {
3641 vos_mem_free(pIes);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003642 }
3643 }
3644
3645 if (fNew)
3646 {
3647 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003648 }
3649 else
3650 {
3651 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
3652 }
3653
3654 return (fNew);
3655}
3656
3657tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
3658 tpAniSirGlobal pMac,
3659 tCsrScanResult *pResult,
3660 tDot11fBeaconIEs *pIes)
3661{
3662 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3663 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
3664 tCsrRoamConnectedProfile *pCurProfile = NULL;
3665 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
3666
3667 if( !(pMac->roam.roamSession
3668 && CSR_IS_SESSION_VALID(pMac, sessionId)))
3669 {
3670 return FALSE;
3671 }
3672
3673 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
3674
3675 if( !pCurProfile)
3676 {
3677 return FALSE;
3678 }
3679
3680 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003681}
3682
3683/* ---------------------------------------------------------------------------
3684
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003685 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003686
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003687 \brief This function is used to prepare a channel list that is derived from
3688 the list of valid channels and does not include those in the occupied
3689 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003690
3691 \param pMac - The handle returned by macOpen.
3692 \param pInputChannelList - The default channels list.
3693 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003694 \param pOutputChannelList - The place to put the non-occupied channel list.
3695 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003696
3697 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3698
3699---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003700VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003701 tpAniSirGlobal pMac,
3702 tANI_U8 *pInputChannelList,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003703 tANI_U8 numOfChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003704 tANI_U8 *pOutputChannelList,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003705 tANI_U8 *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003706 )
3707{
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003708 tANI_U8 i = 0;
3709 tANI_U8 outputNumOfChannels = 0; // Clear the output number of channels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003710 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
3711 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
3712
Kaushik, Sushant925e27d2014-04-08 13:38:04 +05303713 for (i = 0; (i < numOfChannels &&(i < WNI_CFG_VALID_CHANNEL_LIST_LEN)); i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003714 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003715 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
3716 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003717 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05303718 /* DFS channel will be added in the list only when the
3719 DFS Roaming scan flag is enabled*/
3720 if (CSR_IS_CHANNEL_DFS(pInputChannelList[i]))
3721 {
3722 if (pMac->roam.configParam.allowDFSChannelRoam == TRUE)
3723 {
3724 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
3725 }
3726 }
3727 else
3728 {
3729 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
3730 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003731 }
3732 }
3733
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003734 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
3735 "Number of channels in the non-occupied list list=%d"),
3736 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003737
3738 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003739 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003740
3741 return eHAL_STATUS_SUCCESS;
3742}
3743#endif /* FEATURE_WLAN_LFR */
3744
Jeff Johnson295189b2012-06-20 16:38:30 -07003745/* ---------------------------------------------------------------------------
3746
3747 \fn csrNeighborRoamTransitToCFGChanScan
3748
3749 \brief This function is called whenever there is a transition to CFG chan scan
3750 state from any state. It frees up the current channel list and allocates
3751 a new memory for the channels received from CFG item. It then starts the
3752 neighbor scan timer to perform the scan on each channel one by one
3753
3754 \param pMac - The handle returned by macOpen.
3755
3756 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3757
3758---------------------------------------------------------------------------*/
3759VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
3760{
3761 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3762 eHalStatus status = eHAL_STATUS_SUCCESS;
3763 int i = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003764 tANI_U8 numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003765 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003766 tpCsrChannelInfo currChannelListInfo;
Sandeep Puligilla1627d022014-06-03 02:56:25 +05303767 tANI_U8 scanChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3768 int outputNumOfChannels = 0;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003769#ifdef FEATURE_WLAN_LFR
3770 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3771#endif
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003772 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003773
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003774 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003775#ifdef FEATURE_WLAN_ESE
3776 ((pNeighborRoamInfo->isESEAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003777 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003778 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
3779#endif // ESE
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003780 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003782 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003783
3784
3785 /* Free up the channel list and allocate a new memory. This is because we dont know how much
3786 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
3787 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003788 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003790 vos_mem_free(currChannelListInfo->ChannelList);
3791 currChannelListInfo->ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07003792 currChannelListInfo->numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003794
3795 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
3796 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
3797 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003799 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
3800 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003801 status = csrNeighborRoamMergeChannelLists(
3802 pMac,
3803 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3804 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
3805 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003806 0, //NB: If 0, simply copy the input channel list to the output list.
3807 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003808
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003809 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3810 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05303811 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003812 pMac,
3813 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3814 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
3815 channelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05303816 &numOfChannels,
3817 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003818 }
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303819 if(numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3820 {
3821 smsLog(pMac, LOGE, FL("Received wrong number of Channel list"));
3822 return VOS_STATUS_E_INVAL;
3823 }
Sandeep Puligilla1627d022014-06-03 02:56:25 +05303824 /* Remove the DFS channels from CFG channel list when '
3825 gAllowRoamToDFS is disabled */
3826 if ( pMac->roam.configParam.allowDFSChannelRoam == FALSE)
3827 {
3828 for (i=0; i<numOfChannels; i++)
3829 {
3830 if ( !(CSR_IS_CHANNEL_DFS(channelList[i])))
3831 {
3832 scanChannelList[outputNumOfChannels++] = channelList[i];
3833 }
3834 }
3835 }
3836 else
3837 { /* Move all the channels to roam scan channel list */
3838 vos_mem_copy(scanChannelList,
3839 channelList,
3840 numOfChannels * sizeof(tANI_U8));
3841 outputNumOfChannels = numOfChannels;
3842 }
Kanchanapally, Vidyullatha406ef0e2015-03-25 12:23:19 +05303843
3844 if (outputNumOfChannels == 0)
3845 {
3846 smsLog(pMac, LOGE, FL("No channels to scan"));
3847 return VOS_STATUS_E_FAILURE;
3848 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003849 currChannelListInfo->ChannelList =
Sandeep Puligilla1627d022014-06-03 02:56:25 +05303850 vos_mem_malloc(outputNumOfChannels*sizeof(tANI_U8));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003851 if (NULL == currChannelListInfo->ChannelList)
3852 {
3853 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
3854 return VOS_STATUS_E_RESOURCES;
3855 }
Kanchanapally, Vidyullatha406ef0e2015-03-25 12:23:19 +05303856 currChannelListInfo->numOfChannels = outputNumOfChannels;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003857 vos_mem_copy(currChannelListInfo->ChannelList,
Sandeep Puligilla1627d022014-06-03 02:56:25 +05303858 scanChannelList, outputNumOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003859 }
Mukul Sharma20aa6582014-08-07 21:36:12 +05303860
Mukul Sharma20aa6582014-08-07 21:36:12 +05303861
Srikant Kuppa866893f2012-12-27 17:28:14 -08003862#ifdef FEATURE_WLAN_LFR
Srinivas Girigowdade697412013-02-14 16:31:48 -08003863 else if ((pNeighborRoamInfo->uScanMode == DEFAULT_SCAN) &&
3864 (abs(pNeighborRoamInfo->lookupDOWNRssi) >
3865 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold)))
Srikant Kuppa866893f2012-12-27 17:28:14 -08003866 {
3867 /*
3868 * Trigger a contiguous scan on all channels when the
3869 * RSSI in the lookup DOWN notification is below reassoc
3870 * threshold. This will help us find the best available
3871 * candidate and also update the channel cache.
3872 */
3873 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Triggering contiguous scan "
3874 "(lookupDOWNRssi=%d,reassocThreshold=%d)",
3875 pNeighborRoamInfo->lookupDOWNRssi,
3876 pNeighborRoamInfo->cfgParams.neighborReassocThreshold*(-1));
3877
Deepthi Gowri4480a3f2016-05-18 19:30:17 +05303878 pNeighborRoamInfo->scanRequestTimeStamp =
3879 vos_timer_get_system_time();
Srikant Kuppa866893f2012-12-27 17:28:14 -08003880
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05303881 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003882
3883 /* We are about to start a fresh scan cycle,
3884 * purge non-P2P results from the past */
3885 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
Krunal Soni81b24262013-05-15 17:46:41 -07003886
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003887 csrNeighborRoamPerformContiguousBgScan(pMac, sessionId);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003888
3889 /* Transition to CFG_CHAN_LIST_SCAN */
3890 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
Krunal Soni81b24262013-05-15 17:46:41 -07003891
Srikant Kuppa866893f2012-12-27 17:28:14 -08003892 return VOS_STATUS_SUCCESS;
3893 }
3894#endif
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003895 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003896 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003897 numOfChannels = pMac->scan.occupiedChannels.numChannels;
Kiet Lam600d3ca2013-08-31 16:33:32 +05303898 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3899 {
3900 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3901 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003902 if (numOfChannels
3903#ifdef FEATURE_WLAN_LFR
Srinivas Girigowdade697412013-02-14 16:31:48 -08003904 && ((pNeighborRoamInfo->uScanMode == SPLIT_SCAN_OCCUPIED_LIST) ||
3905 (pNeighborRoamInfo->uEmptyScanCount == 0) ||
3906 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003907#endif
3908 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003910 /*
3911 * Always scan channels in the occupied channel list
3912 * before scanning on the non-occupied list.
3913 */
Srinivas Girigowdade697412013-02-14 16:31:48 -08003914 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Switching to occupied channel list"
3915#ifdef FEATURE_WLAN_LFR
3916 "-uScanMode=%d, uEmptyScanCount=%d",
3917 pNeighborRoamInfo->uScanMode,
3918 pNeighborRoamInfo->uEmptyScanCount
3919#endif
3920 );
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003921 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3922 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05303923 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003924 pMac,
3925 pMac->scan.occupiedChannels.channelList,
3926 numOfChannels,
3927 channelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05303928 &numOfChannels,
3929 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003930 }
3931 else
3932 {
3933 vos_mem_copy(channelList,
3934 pMac->scan.occupiedChannels.channelList,
3935 numOfChannels * sizeof(tANI_U8));
3936 }
Sandeep Puligilla1627d022014-06-03 02:56:25 +05303937 /* Remove the DFS channels from CFG channel list when '
3938 gAllowRoamToDFS is disabled */
3939 if ( pMac->roam.configParam.allowDFSChannelRoam == FALSE)
3940 {
3941 for (i=0; i<numOfChannels; i++)
3942 {
3943 if ( !(CSR_IS_CHANNEL_DFS(channelList[i])))
3944 {
3945 scanChannelList[outputNumOfChannels++] = channelList[i];
3946 }
3947 }
3948 }
3949 else
3950 {
3951 vos_mem_copy(scanChannelList,
3952 channelList,
3953 numOfChannels * sizeof(tANI_U8));
3954 outputNumOfChannels = numOfChannels;
3955 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003956
Kanchanapally, Vidyullatha406ef0e2015-03-25 12:23:19 +05303957 if (outputNumOfChannels == 0)
3958 {
3959 smsLog(pMac, LOGE, FL("No channels to scan"));
3960 return VOS_STATUS_E_FAILURE;
3961 }
Sandeep Puligilla1627d022014-06-03 02:56:25 +05303962 currChannelListInfo->ChannelList = vos_mem_malloc(outputNumOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003963 if (NULL == currChannelListInfo->ChannelList)
3964 {
3965 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
3966 return VOS_STATUS_E_RESOURCES;
3967 }
Kanchanapally, Vidyullatha406ef0e2015-03-25 12:23:19 +05303968 currChannelListInfo->numOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003969 vos_mem_copy(currChannelListInfo->ChannelList,
Sandeep Puligilla1627d022014-06-03 02:56:25 +05303970 scanChannelList,
3971 outputNumOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003972 }
3973 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003974 {
3975 /* Scan all channels from non-occupied list */
3976 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
3977 numOfChannels = sizeof(pMac->roam.validChannelList);
3978
3979 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
3980 (tANI_U8 *)pMac->roam.validChannelList,
3981 (tANI_U32 *) &numOfChannels)))
3982 {
3983#ifdef FEATURE_WLAN_LFR
3984 /*
3985 * Prepare non-occupied channel list (channelList)
3986 * from the actual "valid channel list" information
3987 * formed by CSR.
3988 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05303989 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
Srinivas Girigowdade697412013-02-14 16:31:48 -08003990 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
3991 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003992 numOfChannels,
3993 channelList,
3994 &numOfChannels);
3995#else
3996 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
3997 status = csrNeighborRoamMergeChannelLists(
3998 pMac,
3999 (tANI_U8 *)pMac->roam.validChannelList,
4000 numOfChannels, // The number of channels in the validChannelList
4001 channelList,
4002 0, //NB: If 0, simply copy the input channel list to the output list.
4003 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
4004#endif
4005 }
4006 else
4007 {
4008 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07004009 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004011
4012 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
4013 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05304014 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004015 pMac,
4016 (tANI_U8 *)pMac->roam.validChannelList,
4017 numOfChannels,
4018 channelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05304019 &numOfChannels,
4020 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004021 }
4022
Kaushik, Sushantd39915b2014-04-23 15:12:28 +05304023 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
4024 {
4025 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4026 }
Kanchanapally, Vidyullatha406ef0e2015-03-25 12:23:19 +05304027
4028 if (numOfChannels == 0)
4029 {
4030 smsLog(pMac, LOGE, FL("No channels to scan"));
4031 return VOS_STATUS_E_FAILURE;
4032 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004033 currChannelListInfo->ChannelList =
4034 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
4035
4036 if (NULL == currChannelListInfo->ChannelList)
4037 {
4038 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
4039 return VOS_STATUS_E_RESOURCES;
4040 }
Kanchanapally, Vidyullatha406ef0e2015-03-25 12:23:19 +05304041 currChannelListInfo->numOfChannels = numOfChannels;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004042#ifdef FEATURE_WLAN_LFR
4043 vos_mem_copy(currChannelListInfo->ChannelList,
4044 channelList, numOfChannels * sizeof(tANI_U8));
4045#else
4046 vos_mem_copy(currChannelListInfo->ChannelList,
4047 (tANI_U8 *)pMac->roam.validChannelList,
4048 numOfChannels * sizeof(tANI_U8));
4049#endif
4050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 }
4052
Srikant Kuppa866893f2012-12-27 17:28:14 -08004053 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
4054 "Number of channels from CFG (or) (non-)occupied list=%d",
4055 currChannelListInfo->numOfChannels);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004056 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05304058 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004059 "= %d", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 }
4061 }
4062
4063 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
Deepthi Gowri4480a3f2016-05-18 19:30:17 +05304064 pNeighborRoamInfo->scanRequestTimeStamp = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07004065
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304066 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
4068 what palTimerStart expects */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304069 status = vos_timer_start(&pNeighborRoamInfo->neighborScanTimer,
4070 pNeighborRoamInfo->cfgParams.neighborScanPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004071
4072 if (eHAL_STATUS_SUCCESS != status)
4073 {
4074 /* Timer start failed.. */
4075 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004076 vos_mem_free(currChannelListInfo->ChannelList);
4077 currChannelListInfo->ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07004078 currChannelListInfo->numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 return VOS_STATUS_E_FAILURE;
4080 }
4081
4082 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
4083 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05304084 /* We are about to start a fresh scan cycle,
4085 * purge non-P2P results from the past */
4086 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
James Zmuda5ba36d02013-03-14 17:39:07 -07004087
4088 /* We are about to start a fresh scan cycle,
4089 * purge failed pre-auth results from the past */
4090 csrNeighborRoamPurgePreauthFailedList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004091
4092 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
4093 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
4094
4095 return VOS_STATUS_SUCCESS;
4096}
4097
4098/* ---------------------------------------------------------------------------
4099
4100 \fn csrNeighborRoamNeighborLookupUpEvent
4101
4102 \brief This function is called as soon as TL indicates that the current AP's
4103 RSSI is better than the neighbor lookup threshold. Here, we transition to
4104 CONNECTED state and reset all the scan parameters
4105
4106 \param pMac - The handle returned by macOpen.
4107
4108 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
4109
4110---------------------------------------------------------------------------*/
4111VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
4112{
4113 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4114 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07004115 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004116
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 /* Recheck whether the below check is needed. */
Santhosh Kumar Padma8f930ce2014-06-25 15:06:40 +05304118 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
4119 && (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING))
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004121#ifdef FEATURE_WLAN_LFR
4122 if (!csrRoamIsFastRoamEnabled(pMac,pMac->roam.neighborRoamInfo.csrSessionId))
4123 {
4124 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
4125 return eHAL_STATUS_SUCCESS;
4126 }
4127#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004128 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
4129 csrNeighborRoamResetConnectedStateControlInfo(pMac);
4130
Jeff Johnson295189b2012-06-20 16:38:30 -07004131
4132 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
4133 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
4134 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
4135 WLANTL_HO_THRESHOLD_DOWN,
4136 csrNeighborRoamNeighborLookupDOWNCallback,
4137 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08004138#ifdef FEATURE_WLAN_LFR
4139 pNeighborRoamInfo->lookupDOWNRssi = 0;
4140#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
4142 {
4143 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004144 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 }
4146
4147
4148 return vosStatus;
4149}
4150
4151/* ---------------------------------------------------------------------------
4152
4153 \fn csrNeighborRoamNeighborLookupDownEvent
4154
4155 \brief This function is called as soon as TL indicates that the current AP's
4156 RSSI falls below the current eighbor lookup threshold. Here, we transition to
4157 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
4158 a non-11R association.
4159
4160 \param pMac - The handle returned by macOpen.
4161
4162 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
4163
4164---------------------------------------------------------------------------*/
4165VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
4166{
4167 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4168 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
4169 eHalStatus status = eHAL_STATUS_SUCCESS;
4170
4171 switch (pNeighborRoamInfo->neighborRoamState)
4172 {
4173 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
4174
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004175 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
4177 /* De-register Neighbor Lookup threshold callback with TL */
4178 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
4179 WLANTL_HO_THRESHOLD_DOWN,
4180 csrNeighborRoamNeighborLookupDOWNCallback,
4181 VOS_MODULE_ID_SME);
4182
4183 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
4184 {
4185 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004186 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 }
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004188#ifdef FEATURE_WLAN_LFR
4189 if (!csrRoamIsFastRoamEnabled(pMac,pMac->roam.neighborRoamInfo.csrSessionId))
4190 {
4191 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
4192 return eHAL_STATUS_SUCCESS;
4193 }
4194#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004195
4196#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
4197 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
4198 {
4199
4200 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
4201 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
4202 if (VOS_STATUS_SUCCESS != vosStatus)
4203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004204 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 return vosStatus;
4206 }
4207 /* Increment the neighbor report retry count after sending the neighbor request successfully */
4208 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
4209 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
4210 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
4211 }
4212 else
4213#endif
4214 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004215 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or ESE Association:Neighbor Lookup Down event received in CONNECTED state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004216
4217 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
4218 if (VOS_STATUS_SUCCESS != vosStatus)
4219 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08004220 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
4221 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 return vosStatus;
4223 }
4224 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004225 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 -07004226 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004227 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
4228 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 WLANTL_HO_THRESHOLD_UP,
4230 csrNeighborRoamNeighborLookupUPCallback,
4231 VOS_MODULE_ID_SME, pMac);
4232 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
4233 {
4234 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004235 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 }
4237 break;
4238 default:
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05304239 smsLog(pMac, LOGE, FL("DOWN event received in invalid"
4240 "state %s ..Ignoring..."),
4241 macTraceGetNeighbourRoamState(
4242 pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 break;
4244
4245 }
4246 return vosStatus;
4247}
4248
4249/* ---------------------------------------------------------------------------
4250
4251 \fn csrNeighborRoamNeighborLookupUPCallback
4252
4253 \brief This function is registered with TL to indicate whenever the RSSI
4254 gets better than the neighborLookup RSSI Threshold
4255
4256 \param pAdapter - VOS Context
4257 trafficStatus - UP/DOWN indication from TL
4258 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
4259
4260 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
4261
4262---------------------------------------------------------------------------*/
4263VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08004264 v_PVOID_t pUserCtxt,
4265 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07004266{
4267 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
4268 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4269 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
4270
Srinivasdaaec712012-12-12 15:59:44 -08004271 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
4272 rssiNotification,
4273 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07004274
4275 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
4276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004277 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 return VOS_STATUS_SUCCESS;
4279 }
4280
4281 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
4282 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
4283 return vosStatus;
4284}
4285
4286/* ---------------------------------------------------------------------------
4287
4288 \fn csrNeighborRoamNeighborLookupDOWNCallback
4289
4290 \brief This function is registered with TL to indicate whenever the RSSI
4291 falls below the current neighborLookup RSSI Threshold
4292
4293 \param pAdapter - VOS Context
4294 trafficStatus - UP/DOWN indication from TL
4295 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
4296
4297 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
4298
4299---------------------------------------------------------------------------*/
4300VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08004301 v_PVOID_t pUserCtxt,
4302 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07004303{
4304 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
4305 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4306 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
4307
Srinivasdaaec712012-12-12 15:59:44 -08004308 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
4309 rssiNotification,
4310 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07004311
Srikant Kuppa866893f2012-12-27 17:28:14 -08004312#ifdef FEATURE_WLAN_LFR
4313 pNeighborRoamInfo->lookupDOWNRssi = avgRssi;
4314#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
4316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004317 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 return VOS_STATUS_SUCCESS;
4319 }
4320
4321 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
4322 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
4323
4324 return vosStatus;
4325}
4326
4327#ifdef RSSI_HACK
4328extern int dumpCmdRSSI;
4329#endif
4330
4331/* ---------------------------------------------------------------------------
4332
4333 \fn csrNeighborRoamIndicateDisconnect
4334
4335 \brief This function is called by CSR as soon as the station disconnects from
4336 the AP. This function does the necessary cleanup of neighbor roam data
4337 structures. Neighbor roam state transitions to INIT state whenever this
4338 function is called except if the current state is REASSOCIATING
4339
4340 \param pMac - The handle returned by macOpen.
4341 sessionId - CSR session id that got disconnected
4342
4343 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4344
4345---------------------------------------------------------------------------*/
4346eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
4347{
4348 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004349#ifdef FEATURE_WLAN_LFR
4350 tCsrRoamConnectedProfile *pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
4351#endif
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004352 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004353
krunal soni587bf012014-02-04 12:35:11 -08004354 if (NULL == pSession)
4355 {
4356 smsLog(pMac, LOGE, FL("pSession is NULL "));
4357 return eHAL_STATUS_FAILURE;
4358 }
Kaushik, Sushant8489f472014-01-27 11:41:22 +05304359 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05304360 FL("Disconnect indication on session %d in state %s"
4361 "from BSSID : "
4362 MAC_ADDRESS_STR), sessionId,
4363 macTraceGetNeighbourRoamState(
4364 pNeighborRoamInfo->neighborRoamState),
Kaushik, Sushant8489f472014-01-27 11:41:22 +05304365 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07004366
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004367#ifdef FEATURE_WLAN_LFR
4368 /*Free the current previous profile and move the current profile to prev profile.*/
4369 csrRoamFreeConnectProfile(pMac, pPrevProfile);
Srinivas Girigowda254925a2013-06-25 17:54:33 -07004370 csrRoamCopyConnectProfile(pMac, sessionId, pPrevProfile);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004371#endif
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004372 if (NULL != pSession)
4373 {
4374 if (NULL != pSession->pCurRoamProfile)
4375 {
4376 if (VOS_STA_MODE != pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona)
4377 {
4378 smsLog(pMac, LOGE, FL("Ignoring Disconnect indication received from a non STA persona."
4379 "sessionId: %d, csrPersonna %d"), sessionId,
4380 (int)pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona);
4381 return eHAL_STATUS_SUCCESS;
4382 }
4383 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004384
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004385#ifdef FEATURE_WLAN_ESE
4386 if (pSession->connectedProfile.isESEAssoc)
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07004387 {
4388 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID,
4389 sizeof(tSirMacSSid));
4390 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid,
4391 sizeof(tSirMacAddr));
4392 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
4393 pSession->isPrevApInfoValid = TRUE;
4394 pSession->roamTS1 = vos_timer_get_system_time();
4395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004396#endif
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07004397 } //if (NULL != pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -07004398
4399#ifdef RSSI_HACK
4400 dumpCmdRSSI = -40;
4401#endif
4402 switch (pNeighborRoamInfo->neighborRoamState)
4403 {
4404 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
4405 // Stop scan and neighbor refresh timers.
4406 // These are indeed not required when we are in reassociating
4407 // state.
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304408 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
4409 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
4410 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07004411 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
4412 /*
4413 * Disconnect indication during Disassoc Handoff sub-state
4414 * is received when we are trying to disconnect with the old
4415 * AP during roam. BUT, if receive a disconnect indication
4416 * outside of Disassoc Handoff sub-state, then it means that
4417 * this is a genuine disconnect and we need to clean up.
4418 * Otherwise, we will be stuck in reassoc state which will
4419 * in-turn block scans (see csrIsScanAllowed).
4420 */
4421 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07004422 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07004423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 break;
4425
4426 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 csrNeighborRoamResetInitStateControlInfo(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004428#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004429 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004430 {
4431#endif
4432 csrNeighborRoamDeregAllRssiIndication(pMac);
4433#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4434 }
4435#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 break;
4437
Srikant Kuppa866893f2012-12-27 17:28:14 -08004438 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
4439 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07004440 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
Srikant Kuppa866893f2012-12-27 17:28:14 -08004441 csrNeighborRoamResetConnectedStateControlInfo(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004442#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004443 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004444 {
4445#endif
4446 csrNeighborRoamDeregAllRssiIndication(pMac);
4447#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4448 }
4449#endif
Srikant Kuppa866893f2012-12-27 17:28:14 -08004450 break;
4451
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07004452 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
4453 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07004454 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07004455 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004456#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004457 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004458 {
4459#endif
4460 csrNeighborRoamDeregAllRssiIndication(pMac);
4461#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4462 }
4463#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07004464 break;
4465
4466 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
4467 /* Stop pre-auth to reassoc interval timer */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304468 vos_timer_stop(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07004469 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
4470 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
4471 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07004472 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07004473 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07004474 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004475#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004476 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004477 {
4478#endif
4479 csrNeighborRoamDeregAllRssiIndication(pMac);
4480#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4481 }
4482#endif
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07004483 break;
4484
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 default:
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05304486 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event"
4487 "in state %s"),
4488 macTraceGetNeighbourRoamState(
4489 pNeighborRoamInfo->neighborRoamState));
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07004490 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07004492 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07004493 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004495#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4496 /*Inform the Firmware to STOP Scanning as the host has a disconnect.*/
4497 if (csrRoamIsStaMode(pMac, sessionId))
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004498 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004499 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP, REASON_DISCONNECTED);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004500 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004501#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 return eHAL_STATUS_SUCCESS;
4503}
4504
4505/* ---------------------------------------------------------------------------
4506
4507 \fn csrNeighborRoamIndicateConnect
4508
4509 \brief This function is called by CSR as soon as the station connects to an AP.
4510 This initializes all the necessary data structures related to the
4511 associated AP and transitions the state to CONNECTED state
4512
4513 \param pMac - The handle returned by macOpen.
4514 sessionId - CSR session id that got connected
4515 vosStatus - connect status SUCCESS/FAILURE
4516
4517 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4518
4519---------------------------------------------------------------------------*/
4520eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
4521{
4522 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4523 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07004524 VOS_STATUS vstatus;
4525
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004526#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 int init_ft_flag = FALSE;
4528#endif
4529
krunal soni289815a2013-07-16 16:20:19 -07004530 // if session id invalid then we need return failure
4531 if (NULL == pNeighborRoamInfo || !CSR_IS_SESSION_VALID(pMac, sessionId) ||
4532 (NULL == pMac->roam.roamSession[sessionId].pCurRoamProfile))
krunal soni48782522013-06-13 12:24:10 -07004533 {
4534 return eHAL_STATUS_FAILURE;
4535 }
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05304536 smsLog(pMac, LOG2, FL("Connect indication received with session id %d"
4537 "in state %s"),
4538 sessionId, macTraceGetNeighbourRoamState(
4539 pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004540
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004541 // Bail out if this is NOT a STA persona
4542 if (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona != VOS_STA_MODE)
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004543 {
4544 smsLog(pMac, LOGE, FL("Ignoring Connect indication received from a non STA persona."
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004545 "sessionId: %d, csrPersonna %d"),
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004546 sessionId,
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004547 (int)pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona);
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004548 return eHAL_STATUS_SUCCESS;
4549 }
4550
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004551 // if a concurrent session is running
4552#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4553 if (eANI_BOOLEAN_FALSE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
4554 {
4555#endif
4556 if (csrIsConcurrentSessionRunning(pMac))
4557 {
4558 smsLog(pMac, LOGE, FL("Ignoring Connect indication received in multisession %d"),
4559 csrIsConcurrentSessionRunning(pMac));
4560 return eHAL_STATUS_SUCCESS;
4561 }
4562#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4563 }
4564#endif
4565
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 switch (pNeighborRoamInfo->neighborRoamState)
4567 {
4568 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
4569 if (VOS_STATUS_SUCCESS != vosStatus)
4570 {
4571 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
4572 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07004573 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 break;
4575 }
4576 /* Fall through if the status is SUCCESS */
4577 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
4578 /* Reset all the data structures here */
4579 csrNeighborRoamResetInitStateControlInfo(pMac);
4580
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004582
4583#ifdef FEATURE_WLAN_LFR
4584 /*
4585 * Initialize the occupied list ONLY if we are
4586 * transitioning from INIT state to CONNECTED state.
4587 */
4588 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
4589 csrInitOccupiedChannelsList(pMac);
4590#endif
4591 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
4592
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
4594 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
4595 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004596 pNeighborRoamInfo->currentNeighborLookupThreshold =
4597 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
4598#ifdef FEATURE_WLAN_LFR
4599 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -08004600 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004601 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004602#endif
4603
Jeff Johnson295189b2012-06-20 16:38:30 -07004604
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004605#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 /* Now we can clear the preauthDone that was saved as we are connected afresh */
4607 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4608#endif
4609
4610#ifdef WLAN_FEATURE_VOWIFI_11R
4611 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08004612 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
4613 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 {
4615 if (pMac->roam.configParam.isFastTransitionEnabled)
4616 init_ft_flag = TRUE;
4617 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
4618 }
4619 else
4620 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004621 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004622#endif
4623
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004624#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 // Based on the auth scheme tell if we are 11r
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004626 if (pMac->roam.roamSession[sessionId].connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 {
4628 if (pMac->roam.configParam.isFastTransitionEnabled)
4629 init_ft_flag = TRUE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004630 pNeighborRoamInfo->isESEAssoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 }
4632 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004633 pNeighborRoamInfo->isESEAssoc = eANI_BOOLEAN_FALSE;
4634 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isESEAssoc is = %d ft = %d"),
4635 pNeighborRoamInfo->isESEAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07004636
4637#endif
4638
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004639#ifdef FEATURE_WLAN_LFR
4640 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304641 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004642 {
4643 init_ft_flag = TRUE;
4644 }
4645#endif
4646
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004647#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 if ( init_ft_flag == TRUE )
4649 {
4650 /* Initialize all the data structures needed for the 11r FT Preauth */
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
4652 csrNeighborRoamPurgePreauthFailedList(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004653#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004654 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004655 {
4656 /*If this is not a INFRA type BSS, then do not send the command
4657 * down to firmware.Do not send the START command for other session
4658 * connections.*/
4659 if(csrRoamIsStaMode(pMac, sessionId))
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004660 {
4661 pNeighborRoamInfo->uOsRequestedHandoff = 0;
Mukul Sharma9da30f52014-12-05 21:02:56 +05304662 pNeighborRoamInfo->isForcedInitialRoamTo5GH = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05304663 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
4664 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
4665 SIR_BAND_2_4_GHZ))
4666 {
4667 /*
4668 * Keep 5G and Fwr roaming mutually exclusive so do not
4669 * send RSO start Note we have to send RSO start in all
4670 * errro case.
4671 */
4672 smsLog(pMac, LOG1,
4673 FL("Do not send RSO start"
4674 "because 5G force roaming is enabled"));
4675 break;
4676 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004677 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004678 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004679 } else {
4680#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004681
4682 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
4683 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07004684 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 WLANTL_HO_THRESHOLD_DOWN,
4686 csrNeighborRoamNeighborLookupDOWNCallback,
4687 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08004688#ifdef FEATURE_WLAN_LFR
4689 pNeighborRoamInfo->lookupDOWNRssi = 0;
4690#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07004691 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 {
4693 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004694 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vstatus);
Jeff Johnson43971f52012-07-17 12:26:56 -07004695 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004697#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4698 }
4699#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 }
4701#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 break;
4703 default:
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05304704 smsLog(pMac, LOGE, FL("Connect event received in invalid state %s"
4705 "..Ignoring..."),
4706 macTraceGetNeighbourRoamState(
4707 pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 break;
4709 }
4710 return status;
4711}
4712
4713
4714#ifdef WLAN_FEATURE_VOWIFI_11R
4715/* ---------------------------------------------------------------------------
4716
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 \fn csrNeighborRoamPurgePreauthFailedList
4718
4719 \brief This function purges all the MAC addresses in the pre-auth fail list
4720
4721 \param pMac - The handle returned by macOpen.
4722
4723 \return VOID
4724
4725---------------------------------------------------------------------------*/
4726void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
4727{
4728 tANI_U8 i;
4729
4730 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
4731 {
4732 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
4733 }
4734 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
4735
4736 return;
4737}
4738
4739/* ---------------------------------------------------------------------------
4740
4741 \fn csrNeighborRoamInit11rAssocInfo
4742
4743 \brief This function initializes 11r related neighbor roam data structures
4744
4745 \param pMac - The handle returned by macOpen.
4746
4747 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4748
4749---------------------------------------------------------------------------*/
4750eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
4751{
4752 eHalStatus status;
4753 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
4754
4755 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
4756 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
4757 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
4758 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
4759 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
4760 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
4761
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
4763 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
4764 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
4765 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
4766
4767
4768 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
4769 if (eHAL_STATUS_SUCCESS != status)
4770 {
4771 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 return eHAL_STATUS_RESOURCES;
4773 }
4774 return status;
4775}
4776#endif /* WLAN_FEATURE_VOWIFI_11R */
4777
4778/* ---------------------------------------------------------------------------
4779
4780 \fn csrNeighborRoamInit
4781
4782 \brief This function initializes neighbor roam data structures
4783
4784 \param pMac - The handle returned by macOpen.
4785
4786 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4787
4788---------------------------------------------------------------------------*/
4789eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
4790{
4791 eHalStatus status;
4792 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4793
4794 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
4795 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
4796 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
4797 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
4798 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
4799 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
4800 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
4801 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
4802 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
4803 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004804 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
Mukul Sharma20aa6582014-08-07 21:36:12 +05304805 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable = pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004806
Srinivas Girigowdade697412013-02-14 16:31:48 -08004807 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
4809
Hanumantha Reddy Pothulaf7d308c2015-03-24 13:44:52 +05304810 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels != 0)
4811 {
4812 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
4814
Hanumantha Reddy Pothulaf7d308c2015-03-24 13:44:52 +05304815 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
4816 {
4817 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
4818 return eHAL_STATUS_RESOURCES;
4819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004820
Hanumantha Reddy Pothulaf7d308c2015-03-24 13:44:52 +05304821 /* Update the roam global structure from CFG */
4822 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
4824 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Hanumantha Reddy Pothulaf7d308c2015-03-24 13:44:52 +05304825 }
4826 else
4827 {
4828 smsLog(pMac, LOGW,
4829 FL("invalid neighbor roam channel list: %u"),
4830 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
4831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004832
4833 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
4834 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004835#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08004836 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004837 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004838 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Kiet Lam64c1b492013-07-12 13:56:44 +05304839 vos_mem_set(&pNeighborRoamInfo->prevConnProfile, sizeof(tCsrRoamConnectedProfile), 0);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004840#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
4842
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304843 status = vos_timer_init(&pNeighborRoamInfo->neighborScanTimer, VOS_TIMER_TYPE_SW,
Mukul Sharmad177bd52015-01-05 21:03:38 +05304844 csrNeighborRoamNeighborScanTimerCallback, (void *)pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004845
4846 if (eHAL_STATUS_SUCCESS != status)
4847 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08004848 smsLog(pMac, LOGE, FL("Neighbor scan timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4850 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4851 return eHAL_STATUS_RESOURCES;
4852 }
4853
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304854 status = vos_timer_init(&pNeighborRoamInfo->neighborResultsRefreshTimer, VOS_TIMER_TYPE_SW,
Mukul Sharmad177bd52015-01-05 21:03:38 +05304855 csrNeighborRoamResultsRefreshTimerCallback, (void *)pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004856
4857 if (eHAL_STATUS_SUCCESS != status)
4858 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08004859 smsLog(pMac, LOGE, FL("Neighbor results refresh timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4861 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304862 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 return eHAL_STATUS_RESOURCES;
4864 }
4865
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304866 status = vos_timer_init(&pNeighborRoamInfo->emptyScanRefreshTimer, VOS_TIMER_TYPE_SW,
Srinivas Girigowdade697412013-02-14 16:31:48 -08004867 csrNeighborRoamEmptyScanRefreshTimerCallback,
Mukul Sharmad177bd52015-01-05 21:03:38 +05304868 (void *)pMac);
Srinivas Girigowdade697412013-02-14 16:31:48 -08004869
4870 if (eHAL_STATUS_SUCCESS != status)
4871 {
4872 smsLog(pMac, LOGE, FL("Empty scan refresh timer allocation failed"));
4873 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4874 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304875 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4876 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08004877 return eHAL_STATUS_RESOURCES;
4878 }
4879
Mukul Sharma20aa6582014-08-07 21:36:12 +05304880 status = vos_timer_init(&pNeighborRoamInfo->forcedInitialRoamTo5GHTimer, VOS_TIMER_TYPE_SW,
Mukul Sharmad177bd52015-01-05 21:03:38 +05304881 csrForcedInitialRoamTo5GHTimerCallback, (void *)pMac);
Mukul Sharma20aa6582014-08-07 21:36:12 +05304882
4883 if (eHAL_STATUS_SUCCESS != status)
4884 {
4885 smsLog(pMac, LOGE, FL("forcedInitialRoamTo5GHTimer timer allocation failed"));
4886 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4887 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4888 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4889 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
4890 vos_timer_destroy(&pNeighborRoamInfo->emptyScanRefreshTimer);
4891 return eHAL_STATUS_RESOURCES;
4892 }
4893
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
4895 if (eHAL_STATUS_SUCCESS != status)
4896 {
4897 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
4898 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4899 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304900 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4901 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
4902 vos_timer_destroy(&pNeighborRoamInfo->emptyScanRefreshTimer);
Mukul Sharma20aa6582014-08-07 21:36:12 +05304903 vos_timer_destroy(&pNeighborRoamInfo->forcedInitialRoamTo5GHTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 return eHAL_STATUS_RESOURCES;
4905 }
4906
4907 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
4908 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
4909 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4910 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
4911 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
4912
4913#ifdef WLAN_FEATURE_VOWIFI_11R
4914 status = csrNeighborRoamInit11rAssocInfo(pMac);
4915 if (eHAL_STATUS_SUCCESS != status)
4916 {
4917 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
4918 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4919 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304920 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4921 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
4922 vos_timer_destroy(&pNeighborRoamInfo->emptyScanRefreshTimer);
Mukul Sharma20aa6582014-08-07 21:36:12 +05304923 vos_timer_destroy(&pNeighborRoamInfo->forcedInitialRoamTo5GHTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 csrLLClose(&pNeighborRoamInfo->roamableAPList);
4925 return eHAL_STATUS_RESOURCES;
4926 }
4927#endif
4928 /* Initialize this with the current tick count */
Deepthi Gowri4480a3f2016-05-18 19:30:17 +05304929 pNeighborRoamInfo->scanRequestTimeStamp = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07004930
4931 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07004932 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +05304933
4934 //Set the Last Sent Cmd as RSO_STOP
4935 pNeighborRoamInfo->lastSentCmd = ROAM_SCAN_OFFLOAD_STOP;
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 return eHAL_STATUS_SUCCESS;
4937}
4938
4939/* ---------------------------------------------------------------------------
4940
4941 \fn csrNeighborRoamClose
4942
4943 \brief This function closes/frees all the neighbor roam data structures
4944
4945 \param pMac - The handle returned by macOpen.
4946
4947 \return VOID
4948
4949---------------------------------------------------------------------------*/
4950void csrNeighborRoamClose(tpAniSirGlobal pMac)
4951{
4952 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4953
4954 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
4955 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07004956 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 return;
4958 }
4959
4960 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
4961 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4962
4963 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4964
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304965 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4966 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
4967 vos_timer_destroy(&pNeighborRoamInfo->emptyScanRefreshTimer);
Mukul Sharma20aa6582014-08-07 21:36:12 +05304968 vos_timer_destroy(&pNeighborRoamInfo->forcedInitialRoamTo5GHTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004969
4970 /* Should free up the nodes in the list before closing the double Linked list */
4971 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
4972 csrLLClose(&pNeighborRoamInfo->roamableAPList);
4973
4974 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
4975 {
4976 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
4977 }
4978
4979 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4980 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
4981 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
4982 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4983 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
4984 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
4985
4986 /* Free the profile.. */
4987 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08004988#ifdef FEATURE_WLAN_LFR
Sandeep Pc2b00f62012-12-12 16:44:44 -08004989 csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08004990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004991#ifdef WLAN_FEATURE_VOWIFI_11R
4992 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
4994 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
4995 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
4996 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4997 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4998#endif /* WLAN_FEATURE_VOWIFI_11R */
4999
5000 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
5001
5002 return;
5003}
5004
5005/* ---------------------------------------------------------------------------
5006
5007 \fn csrNeighborRoamRequestHandoff
5008
5009 \brief This function triggers actual switching from one AP to the new AP.
5010 It issues disassociate with reason code as Handoff and CSR as a part of
5011 handling disassoc rsp, issues reassociate to the new AP
5012
5013 \param pMac - The handle returned by macOpen.
5014
5015 \return VOID
5016
5017---------------------------------------------------------------------------*/
5018void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
5019{
5020
5021 tCsrRoamInfo roamInfo;
5022 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
5023 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
5024 tCsrNeighborRoamBSSInfo handoffNode;
5025 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
5026 tANI_U32 roamId = 0;
Kiet Lam1cc95392013-11-22 15:59:36 +05305027 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005028
Yue Maef608272013-04-08 23:09:17 -07005029#ifdef FEATURE_WLAN_LFR_METRICS
5030 tCsrRoamInfo *roamInfoMetrics;
5031#endif
5032
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
5034 {
Mahesh A Saptasagar0616f582014-01-13 21:17:53 +05305035 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %s state"),
5036 macTraceGetNeighbourRoamState(
5037 pMac->roam.neighborRoamInfo.neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 return;
5039 }
5040
c_hpothub8bdd362014-10-29 20:49:02 +05305041 if (eANI_BOOLEAN_FALSE ==
5042 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode))
5043 {
5044 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
5045 FL("failed to obtain handoff AP"));
5046 return;
5047 }
5048
5049 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
5050 FL("HANDOFF CANDIDATE BSSID "MAC_ADDRESS_STR),
5051 MAC_ADDR_ARRAY(handoffNode.pBssDescription->bssId));
5052
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
5054 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
5055 eSIR_SME_SUCCESS);
5056
5057 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
5058 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
5059
Yue Maef608272013-04-08 23:09:17 -07005060#ifdef FEATURE_WLAN_LFR_METRICS
5061 /* LFR metrics - pre-auth completion metric.
5062 Send the event to supplicant that pre-auth successfully completed */
5063 roamInfoMetrics = vos_mem_malloc(sizeof(tCsrRoamInfo));
5064 if (NULL == roamInfoMetrics)
5065 {
5066 smsLog(pMac, LOG1, FL("Memory allocation failed!"));
5067 }
5068 else
5069 {
5070 vos_mem_copy((void *)roamInfoMetrics->bssid,
5071 (void *)&handoffNode.pBssDescription->bssId, sizeof(tCsrBssid));
5072 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
5073 roamInfoMetrics, 0, eCSR_ROAM_HANDOVER_SUCCESS, 0);
Mukul Sharmabff8d722014-07-22 18:39:05 +05305074 vos_mem_free(roamInfoMetrics);
Yue Maef608272013-04-08 23:09:17 -07005075 }
5076#endif
5077
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 /* Free the profile.. Just to make sure we dont leak memory here */
5079 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
5080 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
5081 This should happen before issuing disconnect */
Kiet Lam1cc95392013-11-22 15:59:36 +05305082 status = csrRoamCopyConnectedProfile(pMac,
5083 pNeighborRoamInfo->csrSessionId,
5084 &pNeighborRoamInfo->csrNeighborRoamProfile);
5085 if(eHAL_STATUS_SUCCESS != status)
5086 {
5087 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
5088 FL("csrRoamCopyConnectedProfile returned failed %d"), status);
5089 return;
5090 }
5091
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
5093 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
5094
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005095 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07005096
5097 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
5098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005099 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate");
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 return;
5101 }
5102
5103 //notify HDD for handoff, providing the BSSID too
5104 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
5105
5106 vos_mem_copy(roamInfo.bssid,
5107 handoffNode.pBssDescription->bssId,
5108 sizeof( tCsrBssid ));
5109
5110 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
5111
5112
5113 return;
5114}
5115
5116/* ---------------------------------------------------------------------------
5117
5118 \fn csrNeighborRoamIsHandoffInProgress
5119
5120 \brief This function returns whether handoff is in progress or not based on
5121 the current neighbor roam state
5122
5123 \param pMac - The handle returned by macOpen.
5124 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
5125
5126 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
5127
5128---------------------------------------------------------------------------*/
5129tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
5130{
5131 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
5132 return eANI_BOOLEAN_TRUE;
5133
5134 return eANI_BOOLEAN_FALSE;
5135}
5136
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08005137#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07005138/* ---------------------------------------------------------------------------
5139
5140 \fn csrNeighborRoamIs11rAssoc
5141
5142 \brief This function returns whether the current association is a 11r assoc or not
5143
5144 \param pMac - The handle returned by macOpen.
5145
5146 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
5147
5148---------------------------------------------------------------------------*/
5149tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
5150{
5151 return pMac->roam.neighborRoamInfo.is11rAssoc;
5152}
5153#endif /* WLAN_FEATURE_VOWIFI_11R */
5154
5155
5156/* ---------------------------------------------------------------------------
5157
5158 \fn csrNeighborRoamGetHandoffAPInfo
5159
5160 \brief This function returns the best possible AP for handoff. For 11R case, it
5161 returns the 1st entry from pre-auth done list. For non-11r case, it returns
5162 the 1st entry from roamable AP list
5163
5164 \param pMac - The handle returned by macOpen.
5165 pHandoffNode - AP node that is the handoff candidate returned
5166
c_hpothub8bdd362014-10-29 20:49:02 +05305167 \return eANI_BOOLEAN_TRUE if able find handoff AP, eANI_BOOLEAN_FALSE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -07005168
5169---------------------------------------------------------------------------*/
c_hpothub8bdd362014-10-29 20:49:02 +05305170tANI_BOOLEAN csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
Jeff Johnson295189b2012-06-20 16:38:30 -07005171{
5172 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
c_hpothub8bdd362014-10-29 20:49:02 +05305173 tpCsrNeighborRoamBSSInfo pBssNode = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005174
5175 VOS_ASSERT(NULL != pHandoffNode);
5176
5177#ifdef WLAN_FEATURE_VOWIFI_11R
5178 if (pNeighborRoamInfo->is11rAssoc)
5179 {
5180 /* Always the BSS info in the head is the handoff candidate */
5181 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
5182 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
5183 }
5184 else
5185#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005186#ifdef FEATURE_WLAN_ESE
5187 if (pNeighborRoamInfo->isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 {
5189 /* Always the BSS info in the head is the handoff candidate */
5190 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
5191 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
5192 }
5193 else
5194#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005195#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305196 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005197 {
5198 /* Always the BSS info in the head is the handoff candidate */
5199 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
5200 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
5201 }
5202 else
5203#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 {
5205 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
5206 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
5207 }
c_hpothub8bdd362014-10-29 20:49:02 +05305208
5209 if (NULL == pBssNode)
5210 {
5211 return eANI_BOOLEAN_FALSE;
5212 }
5213
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
5215
c_hpothub8bdd362014-10-29 20:49:02 +05305216 return eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005217}
5218
5219/* ---------------------------------------------------------------------------
5220 \brief This function returns TRUE if preauth is completed
5221
5222 \param pMac - The handle returned by macOpen.
5223
5224 \return boolean
5225
5226---------------------------------------------------------------------------*/
5227tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
5228{
5229 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
5230 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
5231}
5232
5233/* ---------------------------------------------------------------------------
5234 \brief In the event that we are associated with AP1 and we have
5235 completed pre auth with AP2. Then we receive a deauth/disassoc from
5236 AP1.
5237 At this point neighbor roam is in pre auth done state, pre auth timer
5238 is running. We now handle this case by stopping timer and clearing
5239 the pre-auth state. We basically clear up and just go to disconnected
5240 state.
5241
5242 \param pMac - The handle returned by macOpen.
5243
5244 \return boolean
5245---------------------------------------------------------------------------*/
5246void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
5247{
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07005248 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
5250 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
5251
5252 // Stop timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05305253 vos_timer_stop(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005254
5255 // Transition to init state
5256 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -07005257 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005258}
5259
Srikant Kuppafef66a72013-01-30 17:32:44 -08005260/* ---------------------------------------------------------------------------
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08005261 \brief This function returns TRUE if background scan triggered by
5262 LFR is in progress.
Srikant Kuppafef66a72013-01-30 17:32:44 -08005263
5264 \param halHandle - The handle from HDD context.
5265
5266 \return boolean
5267
5268---------------------------------------------------------------------------*/
5269tANI_BOOLEAN csrNeighborRoamScanRspPending (tHalHandle hHal)
5270{
5271 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5272 return (pMac->roam.neighborRoamInfo.scanRspPending);
5273}
5274
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08005275/* ---------------------------------------------------------------------------
5276 \brief This function returns TRUE if STA is in the middle of roaming states
5277
5278 \param halHandle - The handle from HDD context.
5279
5280 \return boolean
5281
5282---------------------------------------------------------------------------*/
5283tANI_BOOLEAN csrNeighborMiddleOfRoaming (tHalHandle hHal)
5284{
5285 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5286 tANI_BOOLEAN val = (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
5287 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
5288 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE == pMac->roam.neighborRoamInfo.neighborRoamState) ||
5289 (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState) ||
5290 (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState);
5291 return (val);
5292}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005293#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5294/* ---------------------------------------------------------------------------
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08005295
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005296 \fn csrNeighborRoamCandidateFoundIndHdlr
5297
5298 \brief This function is called by CSR as soon as TL posts the candidate
5299 found indication to SME via MC thread
5300
5301 \param pMac - The handle returned by macOpen.
5302 pMsg - Msg sent by PE
5303
5304 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
5305
5306---------------------------------------------------------------------------*/
5307eHalStatus csrNeighborRoamCandidateFoundIndHdlr(tpAniSirGlobal pMac, void* pMsg)
5308{
5309 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
5310 eHalStatus status = eHAL_STATUS_SUCCESS;
5311 /* we must be in connected state, if not ignore it */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005312 if ((eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
5313 || (pNeighborRoamInfo->uOsRequestedHandoff))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005314 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005315 smsLog(pMac, LOGE, FL("Received in not CONNECTED state OR uOsRequestedHandoff is set. Ignore it"));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005316 status = eHAL_STATUS_FAILURE;
5317 }
5318 else
5319 {
5320 /* We are about to start a fresh scan cycle,
5321 * purge non-P2P results from the past */
5322 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
5323 /* Once it gets the candidates found indication from PE, will issue a scan
5324 - req to PE with “freshScan” in scanreq structure set as follows:
5325 0x42 - Return & purge LFR scan results
5326 */
5327 status = csrScanRequestLfrResult(pMac, pNeighborRoamInfo->csrSessionId,
5328 csrNeighborRoamScanResultRequestCallback, pMac);
5329 }
5330
5331 return status;
5332}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005333
5334/* ---------------------------------------------------------------------------
5335
5336 \fn csrNeighborRoamProcessHandoffReq
5337
5338 \brief This function is called start with the handoff process. First do a
5339 SSID scan for the BSSID provided
5340
5341 \param pMac - The handle returned by macOpen.
5342
5343 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
5344
5345---------------------------------------------------------------------------*/
5346eHalStatus csrNeighborRoamProcessHandoffReq(tpAniSirGlobal pMac)
5347{
5348 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
5349 eHalStatus status = eHAL_STATUS_SUCCESS;
5350 tANI_U32 roamId;
5351 tCsrRoamProfile *pProfile = NULL;
5352 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pNeighborRoamInfo->csrSessionId );
5353 tANI_U8 i = 0;
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +05305354 uint8_t roam_now = 0;
5355 uint8_t roamable_ap_count = 0;
5356 tCsrScanResultFilter scan_filter;
5357 tScanResultHandle scan_result;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005358
krunal soni587bf012014-02-04 12:35:11 -08005359 if (NULL == pSession)
5360 {
5361 smsLog(pMac, LOGE, FL("pSession is NULL "));
5362 return eHAL_STATUS_FAILURE;
5363 }
5364
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005365 do
5366 {
5367 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
Kiet Lam64c1b492013-07-12 13:56:44 +05305368 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5369 if ( NULL == pProfile )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005370 {
5371 smsLog(pMac, LOGE, FL("Memory alloc failed"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305372 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005373 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305374 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005375 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
5376 if(!HAL_STATUS_SUCCESS(status))
5377 {
5378 smsLog(pMac, LOGE, FL("Profile copy failed"));
5379 break;
5380 }
5381
5382 //Add the BSSID & Channel
5383 pProfile->BSSIDs.numOfBSSIDs = 1;
5384 pProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs);
5385 if (NULL == pProfile->BSSIDs.bssid)
5386 {
5387 smsLog(pMac, LOGE, FL("mem alloc failed for BSSID"));
5388 status = eHAL_STATUS_FAILURE;
5389 break;
5390 }
5391
5392 vos_mem_zero(pProfile->BSSIDs.bssid, sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs);
5393
5394 /* Populate the BSSID from handoff info received from HDD */
5395 for (i = 0; i < pProfile->BSSIDs.numOfBSSIDs; i++)
5396 {
5397 vos_mem_copy(&pProfile->BSSIDs.bssid[i],
5398 pNeighborRoamInfo->handoffReqInfo.bssid, sizeof(tSirMacAddr));
5399 }
5400
5401 pProfile->ChannelInfo.numOfChannels = 1;
5402 pProfile->ChannelInfo.ChannelList =
Kiet Lam64c1b492013-07-12 13:56:44 +05305403 vos_mem_malloc(sizeof(*pProfile->ChannelInfo.ChannelList) *
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005404 pProfile->ChannelInfo.numOfChannels);
5405 if (NULL == pProfile->ChannelInfo.ChannelList)
5406 {
5407 smsLog(pMac, LOGE, FL("mem alloc failed for ChannelList"));
5408 status = eHAL_STATUS_FAILURE;
5409 break;
5410 }
5411 pProfile->ChannelInfo.ChannelList[0] = pNeighborRoamInfo->handoffReqInfo.channel;
5412
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +05305413 /*
5414 * For User space connect requests, the scan has already been done.
5415 * So, check if the BSS descriptor exists in the scan cache and
5416 * proceed with the handoff instead of a redundant scan again.
5417 */
5418 if (pNeighborRoamInfo->handoffReqInfo.src == CONNECT_CMD_USERSPACE) {
5419 smsLog(pMac, LOG1, FL("Connect cmd with bssid within same ESS"));
5420 status = csrNeighborRoamPrepareScanProfileFilter(
5421 pMac, &scan_filter);
5422 smsLog(pMac, LOG1, FL("Filter creation status = %d"), status);
5423 status = csrScanGetResult(pMac, &scan_filter, &scan_result);
5424 roam_now = csrNeighborRoamProcessScanResults(pMac, &scan_result);
5425 roamable_ap_count = csrLLCount(&pNeighborRoamInfo->roamableAPList);
5426 csrFreeScanFilter(pMac, &scan_filter);
5427 smsLog(pMac, LOG1, FL("roam_now=%d, roamable_ap_count=%d"),
5428 roam_now, roamable_ap_count);
5429 }
5430 if (roam_now && roamable_ap_count) {
5431 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
5432 } else {
5433 status = csrScanForSSID(pMac, pSession->sessionId,
5434 pProfile, roamId, FALSE);
5435 if(!HAL_STATUS_SUCCESS(status))
5436 smsLog(pMac, LOGE, FL("SSID scan failed"));
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005437 }
5438 }while(0);
5439
5440 if(NULL != pProfile)
5441 {
5442 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05305443 vos_mem_free(pProfile);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005444 }
5445
5446 return status;
5447}
5448
5449/* ---------------------------------------------------------------------------
5450
5451 \fn csrNeighborRoamSssidScanDone
5452
5453 \brief This function is called once SSID scan is done. If SSID scan failed
5454 to find our candidate add an entry to csr scan cache ourself before starting
5455 the handoff process
5456
5457 \param pMac - The handle returned by macOpen.
5458
5459 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
5460
5461---------------------------------------------------------------------------*/
5462eHalStatus csrNeighborRoamSssidScanDone(tpAniSirGlobal pMac, eHalStatus status)
5463{
5464 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
5465 eHalStatus hstatus;
5466
5467 smsLog(pMac, LOGE, FL("called "));
5468
5469 /* we must be in connected state, if not ignore it */
5470 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
5471 {
5472 smsLog(pMac, LOGE, FL("Received in not CONNECTED state. Ignore it"));
5473 return eHAL_STATUS_FAILURE;
5474 }
5475
5476 //if SSID scan failed to find our candidate add an entry to csr scan cache ourself
5477 if(!HAL_STATUS_SUCCESS(status))
5478 {
5479 smsLog(pMac, LOGE, FL("Add an entry to csr scan cache"));
5480 hstatus = csrScanCreateEntryInScanCache(pMac, pNeighborRoamInfo->csrSessionId,
5481 pNeighborRoamInfo->handoffReqInfo.bssid,
5482 pNeighborRoamInfo->handoffReqInfo.channel);
5483 if (eHAL_STATUS_SUCCESS != hstatus)
5484 {
5485 smsLog(pMac, LOGE, FL("csrScanCreateEntryInScanCache failed with status %d"), hstatus);
5486 return eHAL_STATUS_FAILURE;
5487 }
5488 }
5489
5490 /* Now we have completed scanning for the candidate provided by HDD. Let move on to HO*/
5491 hstatus = csrNeighborRoamProcessScanComplete(pMac);
5492
5493 if (eHAL_STATUS_SUCCESS != hstatus)
5494 {
5495 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
5496 return eHAL_STATUS_FAILURE;
5497 }
5498 return eHAL_STATUS_SUCCESS;
5499}
5500
Selvaraj, Sridhar32417ed2016-06-22 15:19:12 +05305501/**
5502 * csr_neighbor_roam_handler_assign_handoff_src() - Assign source of
5503 * roam handoff
5504 * @pNeighborRoamInfo: Pointer to csr neighbor roam control info
5505 * @pHandoffReqInfo: Pointer to the Handoff request
5506 *
5507 * Return: None
5508 */
5509#ifndef QCA_WIFI_ISOC
5510static inline void csr_neighbor_roam_handler_assign_handoff_src(
5511 tpCsrNeighborRoamControlInfo pNeighborRoamInfo,
5512 tAniHandoffReq *pHandoffReqInfo)
5513{
5514 pNeighborRoamInfo->handoffReqInfo.src
5515 = pHandoffReqInfo->handoff_src;
5516}
5517#else
5518static inline void csr_neighbor_roam_handler_assign_handoff_src(
5519 tpCsrNeighborRoamControlInfo pNeighborRoamInfo,
5520 tAniHandoffReq *pHandoffReqInfo)
5521{
5522}
5523#endif
5524
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005525/* ---------------------------------------------------------------------------
5526
5527 \fn csrNeighborRoamHandoffReqHdlr
5528
5529 \brief This function is called by CSR as soon as it gets a handoff request
5530 to SME via MC thread
5531
5532 \param pMac - The handle returned by macOpen.
5533 pMsg - Msg sent by HDD
5534
5535 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
5536
5537---------------------------------------------------------------------------*/
5538eHalStatus csrNeighborRoamHandoffReqHdlr(tpAniSirGlobal pMac, void* pMsg)
5539{
5540 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
5541 tAniHandoffReq *pHandoffReqInfo;
5542 eHalStatus status = eHAL_STATUS_SUCCESS;
5543 /* we must be in connected state, if not ignore it */
5544 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
5545 {
5546 smsLog(pMac, LOGE, FL("Received in not CONNECTED state. Ignore it"));
5547 status = eHAL_STATUS_FAILURE;
5548 }
5549 else
5550 {
5551 //save the handoff info came from HDD as part of the reassoc req
5552 pHandoffReqInfo = (tAniHandoffReq *)pMsg;
5553 if (NULL != pHandoffReqInfo)
5554 {
5555 //sanity check
5556 if (VOS_FALSE == vos_mem_compare(pHandoffReqInfo->bssid,
5557 pNeighborRoamInfo->currAPbssid,
5558 sizeof(tSirMacAddr)))
5559 {
5560
5561 pNeighborRoamInfo->handoffReqInfo.channel = pHandoffReqInfo->channel;
Selvaraj, Sridhar32417ed2016-06-22 15:19:12 +05305562 csr_neighbor_roam_handler_assign_handoff_src(pNeighborRoamInfo,
5563 pHandoffReqInfo);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005564 vos_mem_copy(pNeighborRoamInfo->handoffReqInfo.bssid,
5565 pHandoffReqInfo->bssid,
5566 6);
5567 pNeighborRoamInfo->uOsRequestedHandoff = 1;
5568 status = csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP,
5569 REASON_OS_REQUESTED_ROAMING_NOW);
5570 if (eHAL_STATUS_SUCCESS != status)
5571 {
5572 smsLog(pMac, LOGE, FL("csrRoamOffloadScan failed"));
5573 pNeighborRoamInfo->uOsRequestedHandoff = 0;
5574 }
5575 }
5576 else
5577 {
5578 smsLog(pMac, LOGE, FL("Received req has same BSSID as current AP!!"));
5579 status = eHAL_STATUS_FAILURE;
5580 }
5581 }
5582 else
5583 {
5584 smsLog(pMac, LOGE, FL("Received msg is NULL"));
5585 status = eHAL_STATUS_FAILURE;
5586 }
5587 }
5588
5589 return status;
5590}
5591
5592/* ---------------------------------------------------------------------------
5593
5594 \fn csrNeighborRoamProceedWithHandoffReq
5595
5596 \brief This function is called by CSR as soon as it gets rsp back for
5597 ROAM_SCAN_OFFLOAD_STOP with reason REASON_OS_REQUESTED_ROAMING_NOW
5598
5599 \param pMac - The handle returned by macOpen.
5600
5601 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
5602
5603---------------------------------------------------------------------------*/
5604eHalStatus csrNeighborRoamProceedWithHandoffReq(tpAniSirGlobal pMac)
5605{
5606 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
5607 eHalStatus status = eHAL_STATUS_SUCCESS;
5608 /* we must be in connected state, if not ignore it */
5609 if ((eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
5610 || (!pNeighborRoamInfo->uOsRequestedHandoff))
5611 {
5612 smsLog(pMac, LOGE, FL("Received in not CONNECTED state or uOsRequestedHandoff is not set. Ignore it"));
5613 status = eHAL_STATUS_FAILURE;
5614 }
5615 else
5616 {
5617 //Let's go ahead with handoff
5618 status = csrNeighborRoamProcessHandoffReq(pMac);
5619 }
5620 if(!HAL_STATUS_SUCCESS(status))
5621 {
5622 pNeighborRoamInfo->uOsRequestedHandoff = 0;
5623 }
5624 return status;
5625}
5626
5627/* ---------------------------------------------------------------------------
5628
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07005629 \fn csrNeighborRoamStartLfrScan
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005630
5631 \brief This function is called if HDD requested handoff failed for some
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07005632 reason. start the LFR logic at that point.By the time, this function is
5633 called, a STOP command has already been issued.
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005634
5635 \param pMac - The handle returned by macOpen.
5636
5637 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
5638
5639---------------------------------------------------------------------------*/
Mukul Sharma20aa6582014-08-07 21:36:12 +05305640eHalStatus csrNeighborRoamStartLfrScan(tpAniSirGlobal pMac, tANI_U8 OffloadCmdStopReason)
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005641{
5642 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Mukul Sharma20aa6582014-08-07 21:36:12 +05305643
5644 smsLog(pMac, LOGE,
5645 FL(" uOsRequestedHandoff=%d isForcedInitialRoamTo5GH=%d OffloadCmdStopReason = %d"),
5646 pNeighborRoamInfo->uOsRequestedHandoff,
5647 pNeighborRoamInfo->isForcedInitialRoamTo5GH,
5648 OffloadCmdStopReason);
5649
5650 if(OffloadCmdStopReason == REASON_OS_REQUESTED_ROAMING_NOW)
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005651 pNeighborRoamInfo->uOsRequestedHandoff = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05305652 if(OffloadCmdStopReason == REASON_INITIAL_FORCED_ROAM_TO_5G)
5653 pNeighborRoamInfo->isForcedInitialRoamTo5GH = 0;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005654 /* There is no candidate or We are not roaming Now.
5655 * Inform the FW to restart Roam Offload Scan */
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07005656 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07005657
5658 return eHAL_STATUS_SUCCESS;
5659}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005660#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07005661#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */