blob: 5b4ece61ad0fe9dc648c6e24d183a795014259b3 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
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 \file sme_Rrm.c
31
32 \brief implementation for SME RRM APIs
33
Kiet Lamaa8e15a2014-02-11 23:30:06 -080034 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
35
36 Qualcomm Confidential and Proprietary.
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
40/* $Header$ */
41
42#if defined WLAN_FEATURE_VOWIFI
43/*--------------------------------------------------------------------------
44 Include Files
45 ------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070046#include "aniGlobal.h"
47#include "smeInside.h"
48#include "sme_Api.h"
49#include "smsDebug.h"
50#include "cfgApi.h"
51
52#ifdef FEATURE_WLAN_DIAG_SUPPORT
53#include "vos_diag_core_event.h"
54#include "vos_diag_core_log.h"
55#endif /* FEATURE_WLAN_DIAG_SUPPORT */
56
57#include "csrInsideApi.h"
58
59#include "rrmGlobal.h"
60
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080061#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
62#include "csrEse.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070063#endif
64
65/* Roam score for a neighbor AP will be calculated based on the below definitions.
66 The calculated roam score will be used to select the roamable candidate from neighbor AP list */
67#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_REACHABILITY 0 /* When we support 11r over the DS, this should have a non-zero value */
68#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_SECURITY 10
69#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_KEY_SCOPE 20
70#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_SPECTRUM_MGMT 0 /* Not used */
71#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_QOS 5
72#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_APSD 3
73#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_RRM 8
74#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_DELAYED_BA 0 /* We dont support delayed BA */
75#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_IMMEDIATE_BA 3
76#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_MOBILITY_DOMAIN 30
77
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080078#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070079#define RRM_ROAM_SCORE_NEIGHBOR_IAPP_LIST 30
80#endif
81/**---------------------------------------------------------------------------
82
83 \brief rrmLLPurgeNeighborCache() -
84 This function purges all the entries in the neighbor cache and frees up all the internal nodes
85
86 \param - pMac - Pointer to the Hal Handle.
87 - pList - Pointer the List that should be purged.
88 \return - void
89
90 --------------------------------------------------------------------------*/
91static void rrmLLPurgeNeighborCache(tpAniSirGlobal pMac, tDblLinkList *pList)
92{
93 tListElem *pEntry;
94 tRrmNeighborReportDesc *pNeighborReportDesc;
95
96 csrLLLock(pList);
97
98 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_NOLOCK)) != NULL)
99 {
100 pNeighborReportDesc = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
101 vos_mem_free(pNeighborReportDesc->pNeighborBssDescription);
102 vos_mem_free(pNeighborReportDesc);
103 }
104
105 csrLLUnlock(pList);
106
107 return;
108}
109
110/**---------------------------------------------------------------------------
111
112 \brief rrmIndicateNeighborReportResult() -
113 This function calls the callback register by the caller while requesting for
114 neighbor report. This function gets invoked if a neighbor report is received from an AP
115 or neighbor response wait timer expires.
116
117 \param - pMac - Pointer to the Hal Handle.
118 - vosStatus - VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE based on whether a valid report is
119 received or neighbor timer expired
120 \return - void
121
122 --------------------------------------------------------------------------*/
123void rrmIndicateNeighborReportResult(tpAniSirGlobal pMac, VOS_STATUS vosStatus)
124{
125 NeighborReportRspCallback callback;
126 void *callbackContext;
127
128 /* Reset the neighbor response pending status */
129 pMac->rrm.rrmSmeContext.neighborReqControlInfo.isNeighborRspPending = eANI_BOOLEAN_FALSE;
130
131 /* Stop the timer if it is already running. The timer should be running only in the SUCCESS case. */
132 if (VOS_TIMER_STATE_RUNNING == vos_timer_getCurrentState(&pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspWaitTimer))
133 {
Gopichand Nakkalaecdb2a82013-05-30 12:57:51 +0530134 smsLog( pMac, LOG1, FL("No entry in neighbor report cache"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 vos_timer_stop(&pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspWaitTimer);
136 }
137 callback = pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallback;
138 callbackContext = pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallbackContext;
139
140 /* Reset the callback and the callback context before calling the callback. It is very likely that there may be a registration in
141 callback itself. */
142 pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallback = NULL;
143 pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallbackContext = NULL;
144
145 /* Call the callback with the status received from caller */
146 if (callback)
147 callback(callbackContext, vosStatus);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800148#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 // We came here with IAPP AP List
150 // Make sure we inform CSR of the neighbor list
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800151 // for ESE Associations. First clear the cache.
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800153 if (csrNeighborRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 {
155 ProcessIAPPNeighborAPList(pMac);
156 }
157#endif
158
159 return;
160
161}
162
163/**---------------------------------------------------------------------------
164
165 \brief sme_RrmBeaconReportXmitInd() -
166
167 Create and send the beacon report Xmit ind message to PE.
168
169 \param - pMac - Pointer to the Hal Handle.
170 - pResult - scan result.
171 - measurementDone - flag to indicate that the measurement is done.
172 \return - 0 for success, non zero for failure
173
174 --------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530175static eHalStatus sme_RrmSendBeaconReportXmitInd( tpAniSirGlobal pMac,
176 tCsrScanResultInfo **pResultArr,
177 tANI_U8 measurementDone,
178 tANI_U8 bss_count )
Jeff Johnson295189b2012-06-20 16:38:30 -0700179{
180 tpSirBssDescription pBssDesc = NULL;
181 tpSirBeaconReportXmitInd pBeaconRep;
182 tANI_U16 length, ie_len;
183 tANI_U8 bssCounter=0, msgCounter=0;
184 tCsrScanResultInfo *pCurResult=NULL;
185 eHalStatus status = eHAL_STATUS_FAILURE;
186 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
187
188
189#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800190 smsLog( pMac, LOGE, "Beacon report xmit Ind to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700191#endif
192
193 if( NULL == pResultArr && !measurementDone )
194 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800195 smsLog( pMac, LOGE, "Beacon report xmit Ind to PE Failed");
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 return eHAL_STATUS_FAILURE;
197 }
198
199 if (pResultArr)
200 pCurResult=pResultArr[bssCounter];
201
202 do
203 {
204 length = sizeof(tSirBeaconReportXmitInd);
205 pBeaconRep = vos_mem_malloc ( length );
206 if ( NULL == pBeaconRep )
207 {
208 smsLog( pMac, LOGP, "Unable to allocate memory for beacon report");
209 return eHAL_STATUS_FAILED_ALLOC;
210 }
211 vos_mem_zero( pBeaconRep, length );
212#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800213 smsLog( pMac, LOGE, FL("Allocated memory for pBeaconRep"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700214#endif
215 pBeaconRep->messageType = eWNI_SME_BEACON_REPORT_RESP_XMIT_IND;
216 pBeaconRep->length = length;
217 pBeaconRep->uDialogToken = pSmeRrmContext->token;
Kanchanapally, Vidyullatha80cd3d02014-02-10 13:06:41 +0530218 pBeaconRep->duration = pSmeRrmContext->duration[0];
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 pBeaconRep->regClass = pSmeRrmContext->regClass;
220 vos_mem_copy( pBeaconRep->bssId, pSmeRrmContext->sessionBssId, sizeof(tSirMacAddr) );
221
222 msgCounter=0;
223 while (pCurResult)
224 {
225 pBssDesc = &pCurResult->BssDescriptor;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530226 if(pBssDesc != NULL)
227 {
228 ie_len = GET_IE_LEN_IN_BSS( pBssDesc->length );
229 pBeaconRep->pBssDescription[msgCounter] = vos_mem_malloc (
230 ie_len+sizeof(tSirBssDescription));
231 if (NULL == pBeaconRep->pBssDescription[msgCounter])
232 break;
233 vos_mem_copy( pBeaconRep->pBssDescription[msgCounter],
234 pBssDesc,
235 sizeof(tSirBssDescription) );
236 vos_mem_copy( &pBeaconRep->pBssDescription[msgCounter]->ieFields[0],
237 pBssDesc->ieFields, ie_len );
238 smsLog( pMac, LOG1,
Arif Hussain24bafea2013-11-15 15:10:03 -0800239 "...RRM Result Bssid = "MAC_ADDRESS_STR" chan= %d, rssi = -%d",
240 MAC_ADDR_ARRAY(pBeaconRep->pBssDescription[msgCounter]->bssId),
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530241 pBeaconRep->pBssDescription[msgCounter]->channelId,
242 pBeaconRep->pBssDescription[msgCounter]->rssi * (-1));
Jeff Johnson295189b2012-06-20 16:38:30 -0700243
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530244 pBeaconRep->numBssDesc++;
Jeff Johnson295189b2012-06-20 16:38:30 -0700245
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800246 if (++msgCounter >= SIR_BCN_REPORT_MAX_BSS_DESC)
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530247 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530249 pCurResult = pResultArr[bssCounter + msgCounter];
250 }
251 else
252 {
253 pCurResult = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 break;
255 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 }
257
258 bssCounter+=msgCounter;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530259 if (!pResultArr || (pCurResult == NULL) || (bssCounter >= bss_count))
260 {
261 pCurResult = NULL;
262 smsLog(pMac, LOG1,
263 "Reached to the max/last BSS in pCurResult list");
264 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 else
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530266 {
267 pCurResult = pResultArr[bssCounter];
268 smsLog(pMac, LOG1,
269 "Move to the next BSS set in pCurResult list");
270 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700271
272 pBeaconRep->fMeasureDone = (pCurResult)?false:measurementDone;
273
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530274 smsLog(pMac, LOG1,
275 "SME Sending BcnRepXmit to PE numBss %d msgCounter %d bssCounter %d",
276 pBeaconRep->numBssDesc, msgCounter, bssCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
Jeff Johnson0282cf02013-04-03 17:30:03 -0700278 status = palSendMBMessage(pMac->hHdd, pBeaconRep);
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280 } while (pCurResult);
281
282 return status;
283}
284
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800285#if defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800286/**---------------------------------------------------------------------------
287
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800288 \brief sme_EseSendBeaconReqScanResults()
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800289
290 This function sends up the scan results received as a part of
291 beacon request scanning.
292 This function is called after receiving the scan results per channel
293 Due to the limitation on the size of the IWEVCUSTOM buffer, we send 3 BSSIDs of
294 beacon report information in one custom event;
295
296 \param - pMac - Pointer to the Hal Handle.
297 - sessionId - Session id
298 - channel - scan results belongs to this channel
299 - pResultArr - scan result.
300 - measurementDone - flag to indicate that the measurement is done.
301 - bss_count - number of bss found
302 \return - 0 for success, non zero for failure
303
304 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800305static eHalStatus sme_EseSendBeaconReqScanResults(tpAniSirGlobal pMac,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800306 tANI_U32 sessionId,
307 tANI_U8 channel,
308 tCsrScanResultInfo **pResultArr,
309 tANI_U8 measurementDone,
310 tANI_U8 bss_count)
311{
312 eHalStatus status = eHAL_STATUS_FAILURE;
Varun Reddy Yeturucf02bc22013-12-06 18:18:50 -0800313 tSirRetStatus fillIeStatus;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800314 tpSirBssDescription pBssDesc = NULL;
315 tANI_U32 ie_len = 0;
316 tANI_U32 outIeLen = 0;
317 tANI_U8 bssCounter = 0;
318 tCsrScanResultInfo *pCurResult = NULL;
319 tANI_U8 msgCounter = 0;
320 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
321 tCsrRoamInfo roamInfo;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800322 tSirEseBcnReportRsp bcnReport;
323 tpSirEseBcnReportRsp pBcnReport = &bcnReport;
324 tpCsrEseBeaconReqParams pCurMeasReqIe = NULL;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800325 tANI_U8 i = 0;
326
327 if (NULL == pSmeRrmContext)
328 {
329 smsLog( pMac, LOGE, "pSmeRrmContext is NULL");
330 return eHAL_STATUS_FAILURE;
331 }
332
333 if (NULL == pResultArr && !measurementDone)
334 {
335 smsLog( pMac, LOGE, "Beacon report xmit Ind to HDD Failed");
336 return eHAL_STATUS_FAILURE;
337 }
338
339 if (pResultArr)
340 pCurResult=pResultArr[bssCounter];
341
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800342 vos_mem_zero(&bcnReport, sizeof(tSirEseBcnReportRsp));
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800343 do
344 {
345 pCurMeasReqIe = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800346 for (i = 0; i < pSmeRrmContext->eseBcnReqInfo.numBcnReqIe; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800347 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800348 if(pSmeRrmContext->eseBcnReqInfo.bcnReq[i].channel == channel)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800349 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800350 pCurMeasReqIe = &pSmeRrmContext->eseBcnReqInfo.bcnReq[i];
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800351 break;
352 }
353 }
Padma, Santhosh Kumar795a3b02014-01-17 21:28:26 +0530354 if(NULL != pCurMeasReqIe)
355 pBcnReport->measurementToken = pCurMeasReqIe->measurementToken;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800356 smsLog( pMac, LOG1, "Channel(%d) MeasToken(%d)", channel, pBcnReport->measurementToken);
357
358 msgCounter=0;
359 while (pCurResult)
360 {
361 pBssDesc = &pCurResult->BssDescriptor;
362 if (NULL != pBssDesc)
363 {
364 ie_len = GET_IE_LEN_IN_BSS( pBssDesc->length );
365 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.ChanNum = pBssDesc->channelId;
366 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.Spare = 0;
Padma, Santhosh Kumar795a3b02014-01-17 21:28:26 +0530367 if(NULL != pCurMeasReqIe)
368 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.MeasDuration = pCurMeasReqIe->measurementDuration;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800369 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.PhyType = pBssDesc->nwType;
370 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.RecvSigPower = pBssDesc->rssi;
371 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.ParentTsf = pBssDesc->parentTSF;
372 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.TargetTsf[0] = pBssDesc->timeStamp[0];
373 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.TargetTsf[1] = pBssDesc->timeStamp[1];
374 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.BcnInterval = pBssDesc->beaconInterval;
375 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.CapabilityInfo = pBssDesc->capabilityInfo;
376 vos_mem_copy(pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.Bssid,
377 pBssDesc->bssId, sizeof(tSirMacAddr));
378
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800379 fillIeStatus = sirFillBeaconMandatoryIEforEseBcnReport(pMac,
Varun Reddy Yeturucf02bc22013-12-06 18:18:50 -0800380 (tANI_U8 *)pBssDesc->ieFields,
381 ie_len,
382 &(pBcnReport->bcnRepBssInfo[msgCounter].pBuf),
383 &outIeLen);
384 if (eSIR_FAILURE == fillIeStatus)
385 {
386 continue;
387 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800388 pBcnReport->bcnRepBssInfo[msgCounter].ieLen = outIeLen;
389
Arif Hussaina7c8e412013-11-20 11:06:42 -0800390 smsLog( pMac, LOG1,"Bssid("MAC_ADDRESS_STR") Channel=%d Rssi=%d",
391 MAC_ADDR_ARRAY(pBssDesc->bssId),
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800392 pBssDesc->channelId, (-1) * pBssDesc->rssi);
393
394 pBcnReport->numBss++;
395
396 if (++msgCounter >= SIR_BCN_REPORT_MAX_BSS_DESC)
397 break;
398
399 pCurResult = pResultArr[msgCounter];
400 }
401 else
402 {
403 pCurResult = NULL;
404 break;
405 }
406 }
407
408 bssCounter += msgCounter;
409 if (!pResultArr || !pCurResult || (bssCounter >= SIR_BCN_REPORT_MAX_BSS_DESC))
410 {
411 pCurResult = NULL;
412 smsLog(pMac, LOGE,
413 "Reached to the max/last BSS in pCurResult list");
414 }
415 else
416 {
417 pCurResult = pResultArr[bssCounter];
418 smsLog(pMac, LOGE,
419 "Move to the next BSS set in pCurResult list");
420 }
421
422 pBcnReport->flag = (measurementDone << 1)|((pCurResult)?true:false);
423
424 smsLog(pMac, LOG1, "SME Sending BcnRep to HDD numBss(%d)"
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800425 " msgCounter(%d) bssCounter(%d) flag(%d)",
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800426 pBcnReport->numBss, msgCounter, bssCounter, pBcnReport->flag);
427
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800428 roamInfo.pEseBcnReportRsp = pBcnReport;
429 status = csrRoamCallCallback(pMac, sessionId, &roamInfo,
430 0, eCSR_ROAM_ESE_BCN_REPORT_IND, 0);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800431
432 /* Free the memory allocated to IE */
433 for (i = 0; i < msgCounter; i++)
434 {
435 if (pBcnReport->bcnRepBssInfo[i].pBuf)
436 vos_mem_free(pBcnReport->bcnRepBssInfo[i].pBuf);
437 }
438 } while (pCurResult);
439 return status;
440}
441
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800442#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800443
Jeff Johnson295189b2012-06-20 16:38:30 -0700444/**---------------------------------------------------------------------------
445
446 \brief sme_RrmSendScanRequest() -
447
448 This function is called to get the scan result from CSR and send the beacon report
449 xmit ind message to PE.
450
451 \param - pMac - Pointer to the Hal Handle.
452 - num_chan - number of channels.
453 - channel list - list of channels to fetch the result from.
454 - measurementDone - flag to indicate that the measurement is done.
455 \return - 0 for success, non zero for failure
456
457 --------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530458static eHalStatus sme_RrmSendScanResult( tpAniSirGlobal pMac,
459 tANI_U8 num_chan,
460 tANI_U8* chanList,
461 tANI_U8 measurementDone )
Jeff Johnson295189b2012-06-20 16:38:30 -0700462{
463 tCsrScanResultFilter filter;
464 tScanResultHandle pResult;
465 tCsrScanResultInfo *pScanResult, *pNextResult;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800466 tCsrScanResultInfo *pScanResultsArr[SIR_BCN_REPORT_MAX_BSS_DESC];
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 eHalStatus status;
468 tANI_U8 counter=0;
469 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
470 tANI_U32 sessionId;
471
472#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800473 smsLog( pMac, LOGE, "Send scan result to PE ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700474#endif
475
476 vos_mem_zero( &filter, sizeof(filter) );
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800477 vos_mem_zero( pScanResultsArr, sizeof(pNextResult)*SIR_BCN_REPORT_MAX_BSS_DESC );
Jeff Johnson295189b2012-06-20 16:38:30 -0700478
479 filter.BSSIDs.numOfBSSIDs = 1;
480 filter.BSSIDs.bssid = &pSmeRrmContext->bssId;
481
482 if( pSmeRrmContext->ssId.length )
483 {
484 filter.SSIDs.SSIDList =( tCsrSSIDInfo *)vos_mem_malloc(sizeof(tCsrSSIDInfo));
485 if( filter.SSIDs.SSIDList == NULL )
486 {
487 smsLog( pMac, LOGP, FL("vos_mem_malloc failed:") );
488 return eHAL_STATUS_FAILURE;
489 }
490#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800491 smsLog( pMac, LOGE, FL("Allocated memory for SSIDList"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700492#endif
493 vos_mem_zero( filter.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) );
494
495 filter.SSIDs.SSIDList->SSID.length = pSmeRrmContext->ssId.length;
496 vos_mem_copy(filter.SSIDs.SSIDList->SSID.ssId, pSmeRrmContext->ssId.ssId, pSmeRrmContext->ssId.length);
497 filter.SSIDs.numOfSSIDs = 1;
498 }
499 else
500 {
501 filter.SSIDs.numOfSSIDs = 0;
502 }
503
504 filter.ChannelInfo.numOfChannels = num_chan;
505 filter.ChannelInfo.ChannelList = chanList;
506
507 filter.fMeasurement = TRUE;
508
509 csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid*)pSmeRrmContext->sessionBssId, &sessionId );
510 status = sme_ScanGetResult(pMac, (tANI_U8)sessionId, &filter, &pResult);
511
512 if( filter.SSIDs.SSIDList )
513 {
514 //Free the memory allocated for SSIDList.
515 vos_mem_free( filter.SSIDs.SSIDList );
516#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800517 smsLog( pMac, LOGE, FL("Free memory for SSIDList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700518#endif
519 }
520
521 if (NULL == pResult)
522 {
523 // no scan results
524 //
525 // Spec. doesnt say anything about such condition.
526 // Since section 7.4.6.2 (IEEE802.11k-2008) says-rrm report frame should contain
527 // one or more report IEs. It probably means dont send any respose if no matching
528 // BSS found. Moreover, there is no flag or field in measurement report IE(7.3.2.22)
529 // OR beacon report IE(7.3.2.22.6) that can be set to indicate no BSS found on a given channel.
530 //
531 // If we finished measurement on all the channels, we still need to
532 // send a xmit indication with moreToFollow set to MEASURMENT_DONE
533 // so that PE can clean any context allocated.
534 if( measurementDone )
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800535 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800536#if defined(FEATURE_WLAN_ESE_UPLOAD)
537 if (eRRM_MSG_SOURCE_ESE_UPLOAD == pSmeRrmContext->msgSource)
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800538 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800539 status = sme_EseSendBeaconReqScanResults(pMac,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800540 sessionId,
541 chanList[0],
542 NULL,
543 measurementDone,
544 0);
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800545 }
546 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800547#endif /*FEATURE_WLAN_ESE_UPLOAD*/
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800548 status = sme_RrmSendBeaconReportXmitInd( pMac, NULL, measurementDone, 0);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800549 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 return status;
551 }
552
553 pScanResult = sme_ScanResultGetFirst(pMac, pResult);
554
555 if( NULL == pScanResult && measurementDone )
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800556 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800557#if defined(FEATURE_WLAN_ESE_UPLOAD)
558 if (eRRM_MSG_SOURCE_ESE_UPLOAD == pSmeRrmContext->msgSource)
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800559 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800560 status = sme_EseSendBeaconReqScanResults(pMac,
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800561 sessionId,
562 chanList[0],
563 NULL,
564 measurementDone,
565 0);
566 }
567 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800568#endif /*FEATURE_WLAN_ESE_UPLOAD*/
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800569 status = sme_RrmSendBeaconReportXmitInd( pMac, NULL, measurementDone, 0 );
570 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700571
572 counter=0;
573 while (pScanResult)
574 {
575 pNextResult = sme_ScanResultGetNext(pMac, pResult);
576 pScanResultsArr[counter++] = pScanResult;
577 pScanResult = pNextResult; //sme_ScanResultGetNext(hHal, pResult);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800578 if (counter >= SIR_BCN_REPORT_MAX_BSS_DESC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 break;
580 }
581
582 if (counter)
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530583 {
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800584 smsLog(pMac, LOG1, " Number of BSS Desc with RRM Scan %d ", counter);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800585#if defined(FEATURE_WLAN_ESE_UPLOAD)
586 if (eRRM_MSG_SOURCE_ESE_UPLOAD == pSmeRrmContext->msgSource)
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800587 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800588 status = sme_EseSendBeaconReqScanResults(pMac,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800589 sessionId,
590 chanList[0],
591 pScanResultsArr,
592 measurementDone,
593 counter);
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800594 }
595 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800596#endif /*FEATURE_WLAN_ESE_UPLOAD*/
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800597 status = sme_RrmSendBeaconReportXmitInd( pMac,
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530598 pScanResultsArr,
599 measurementDone,
600 counter);
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530601 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 sme_ScanResultPurge(pMac, pResult);
603
604 return status;
605}
606/**---------------------------------------------------------------------------
607
608 \brief sme_RrmScanRequestCallback() -
609
610 The sme module calls this callback function once it finish the scan request
611 and this function send the beacon report xmit to PE and starts a timer of
612 random interval to issue next request.
613
614 \param - halHandle - Pointer to the Hal Handle.
615 - pContext - Pointer to the data context.
616 - scanId - Scan ID.
617 - status - CSR Status.
618 \return - 0 for success, non zero for failure
619
620 --------------------------------------------------------------------------*/
621
622static eHalStatus sme_RrmScanRequestCallback(tHalHandle halHandle, void *pContext,
623 tANI_U32 scanId, eCsrScanStatus status)
624{
625
626 tANI_U16 interval;
627 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
628 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
629 tANI_U32 time_tick;
630
631
632
633#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800634 smsLog( pMac, LOGE, "Scan Request callback ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700635#endif
636 //if any more channels are pending, start a timer of a random value within randomization interval.
637 //
638 //
639 if( (pSmeRrmContext->currentIndex + 1) < pSmeRrmContext->channelList.numOfChannels )
640 {
641 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], false );
642
643 pSmeRrmContext->currentIndex++; //Advance the current index.
644 //start the timer to issue next request.
645 //From timer tick get a random number within 10ms and max randmization interval.
646 time_tick = vos_timer_get_system_ticks();
647 interval = time_tick % (pSmeRrmContext->randnIntvl - 10 + 1) + 10;
648
649#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800650 smsLog( pMac, LOGE, "Set timer for interval %d ", interval);
Jeff Johnson295189b2012-06-20 16:38:30 -0700651#endif
652 vos_timer_start( &pSmeRrmContext->IterMeasTimer, interval );
653
654 }
655 else
656 {
657 //Done with the measurement. Clean up all context and send a message to PE with measurement done flag set.
658 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], true );
659 vos_mem_free( pSmeRrmContext->channelList.ChannelList );
660#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800661 smsLog( pMac, LOGE, FL("Free memory for ChannelList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700662#endif
663 }
664
665 return eHAL_STATUS_SUCCESS;
666}
667
668/*--------------------------------------------------------------------------
669 \brief sme_RrmIssueScanReq() - This is called to send a scan request as part
670 of beacon report request .
671
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800672 \param pMac - pMac global pointer
Jeff Johnson295189b2012-06-20 16:38:30 -0700673
674 \return eHAL_STATUS_SUCCESS - Validation is successful.
675
676 \sa
677
678 --------------------------------------------------------------------------*/
679eHalStatus sme_RrmIssueScanReq( tpAniSirGlobal pMac )
680{
681 //Issue scan request.
682 tCsrScanRequest scanRequest;
683 v_U32_t scanId = 0;
684 eHalStatus status = eHAL_STATUS_SUCCESS;
685 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
686 tANI_U32 sessionId;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800687 tSirScanType scanType;
Jeff Johnson295189b2012-06-20 16:38:30 -0700688
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800689 if ((pSmeRrmContext->currentIndex) >= pSmeRrmContext->channelList.numOfChannels)
690 return status;
691
692 scanType = pSmeRrmContext->measMode[pSmeRrmContext->currentIndex];
693 if ((eSIR_ACTIVE_SCAN == scanType) || (eSIR_PASSIVE_SCAN == scanType))
694 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700695#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800696 smsLog( pMac, LOGE, "Issue scan request " );
Jeff Johnson295189b2012-06-20 16:38:30 -0700697#endif
698
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800699 vos_mem_zero( &scanRequest, sizeof(scanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -0700700
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800701 /* set scanType, active or passive */
702 scanRequest.bcnRptReqScan = TRUE;
703 scanRequest.scanType = scanType;
Jeff Johnson295189b2012-06-20 16:38:30 -0700704
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800705 vos_mem_copy(scanRequest.bssid,
706 pSmeRrmContext->bssId, sizeof(scanRequest.bssid) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700707
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800708 if (pSmeRrmContext->ssId.length)
709 {
710 scanRequest.SSIDs.numOfSSIDs = 1;
711 scanRequest.SSIDs.SSIDList =( tCsrSSIDInfo *)vos_mem_malloc(sizeof(tCsrSSIDInfo));
712 if (NULL == scanRequest.SSIDs.SSIDList)
713 {
714 smsLog( pMac, LOGP, FL("vos_mem_malloc failed:") );
715 return eHAL_STATUS_FAILURE;
716 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700717#if defined WLAN_VOWIFI_DEBUG
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800718 smsLog( pMac, LOGE, FL("Allocated memory for pSSIDList"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700719#endif
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800720 vos_mem_zero( scanRequest.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) );
721 scanRequest.SSIDs.SSIDList->SSID.length = pSmeRrmContext->ssId.length;
722 vos_mem_copy(scanRequest.SSIDs.SSIDList->SSID.ssId, pSmeRrmContext->ssId.ssId, pSmeRrmContext->ssId.length);
723 }
724
725 /* set min and max channel time */
726 scanRequest.minChnTime = 0; //pSmeRrmContext->duration; Dont use min timeout.
727 scanRequest.maxChnTime = pSmeRrmContext->duration[pSmeRrmContext->currentIndex];
728 smsLog( pMac, LOG1, "Scan Type(%d) Max Dwell Time(%d)", scanRequest.scanType,
729 scanRequest.maxChnTime );
730
731#if defined WLAN_VOWIFI_DEBUG
732 smsLog( pMac, LOGE, "For Duration %d ", scanRequest.maxChnTime );
733#endif
734
735 /* set BSSType to default type */
736 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
737
738 /*Scan all the channels */
739 scanRequest.ChannelInfo.numOfChannels = 1;
740
741 scanRequest.ChannelInfo.ChannelList = &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex];
742#if defined WLAN_VOWIFI_DEBUG
743 smsLog( pMac, LOGE, "On channel %d ", pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex] );
744#endif
745
746 /* set requestType to full scan */
747 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
748
749 csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid*)pSmeRrmContext->sessionBssId, &sessionId );
750 status = sme_ScanRequest( pMac, (tANI_U8)sessionId, &scanRequest, &scanId, &sme_RrmScanRequestCallback, NULL );
751
752 if ( pSmeRrmContext->ssId.length )
753 {
754 vos_mem_free(scanRequest.SSIDs.SSIDList);
755#if defined WLAN_VOWIFI_DEBUG
756 smsLog( pMac, LOGE, FL("Free memory for SSIDList"));
757#endif
758 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800760 else if (2 == scanType) /* beacon table */
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 {
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800762 if ((pSmeRrmContext->currentIndex + 1) < pSmeRrmContext->channelList.numOfChannels)
763 {
764 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], false );
765 pSmeRrmContext->currentIndex++; //Advance the current index.
766 sme_RrmIssueScanReq(pMac);
767 }
768 else
769 {
770 //Done with the measurement. Clean up all context and send a message to PE with measurement done flag set.
771 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], true );
772 vos_mem_free( pSmeRrmContext->channelList.ChannelList );
773 }
774 }
775 else
776 {
777 smsLog( pMac, LOGE, "Unknown beacon report request mode(%d)", scanType);
778 /* Indicate measurement completion to PE */
779 /* If this is not done, pCurrentReq pointer will not be freed and
780 PE will not handle subsequent Beacon requests */
781 sme_RrmSendBeaconReportXmitInd(pMac, NULL, true, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 }
783
784 return status;
785}
786
787/*--------------------------------------------------------------------------
788 \brief sme_RrmProcessBeaconReportReqInd() - This is called to process the Beacon
789 report request from peer AP forwarded through PE .
790
791 \param pMsgBuf - a pointer to a buffer that maps to various structures base
792 on the message type.
793 The beginning of the buffer can always map to tSirSmeRsp.
794
795 \return eHAL_STATUS_SUCCESS - Validation is successful.
796
797 \sa
798
799 --------------------------------------------------------------------------*/
800void sme_RrmProcessBeaconReportReqInd(tpAniSirGlobal pMac, void *pMsgBuf)
801{
802 tpSirBeaconReportReqInd pBeaconReq = (tpSirBeaconReportReqInd) pMsgBuf;
803 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800804 tANI_U32 len = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700805
806#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800807 smsLog( pMac, LOGE, "Received Beacon report request ind Channel = %d", pBeaconReq->channelInfo.channelNum );
Jeff Johnson295189b2012-06-20 16:38:30 -0700808#endif
809 //section 11.10.8.1 (IEEE Std 802.11k-2008)
810 //channel 0 and 255 has special meaning.
811 if( (pBeaconReq->channelInfo.channelNum == 0) ||
812 ((pBeaconReq->channelInfo.channelNum == 255) && (pBeaconReq->channelList.numChannels == 0) ) )
813 {
814 //Add all the channel in the regulatory domain.
815 wlan_cfgGetStrLen( pMac, WNI_CFG_VALID_CHANNEL_LIST, &len );
816 pSmeRrmContext->channelList.ChannelList = vos_mem_malloc( len );
817 if( pSmeRrmContext->channelList.ChannelList == NULL )
818 {
819 smsLog( pMac, LOGP, FL("vos_mem_malloc failed:") );
820 return;
821 }
822#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800823 smsLog( pMac, LOGE, FL("Allocated memory for ChannelList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700824#endif
825 csrGetCfgValidChannels( pMac, pSmeRrmContext->channelList.ChannelList, &len );
826 pSmeRrmContext->channelList.numOfChannels = (tANI_U8)len;
827#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800828 smsLog( pMac, LOGE, "channel == 0 performing on all channels");
Jeff Johnson295189b2012-06-20 16:38:30 -0700829#endif
830 }
831 else
832 {
833 len = 0;
834 pSmeRrmContext->channelList.numOfChannels = 0;
835
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800836 //If valid channel is present. We first Measure on the given channel. and
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 //if there are additional channels present in APchannelreport, measure on these also.
838 if ( pBeaconReq->channelInfo.channelNum != 255 )
839 len = 1;
840#if defined WLAN_VOWIFI_DEBUG
841 else
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800842 smsLog( pMac, LOGE, "channel == 255");
Jeff Johnson295189b2012-06-20 16:38:30 -0700843#endif
844
845 len += pBeaconReq->channelList.numChannels;
846
847 pSmeRrmContext->channelList.ChannelList = vos_mem_malloc( len );
848 if( pSmeRrmContext->channelList.ChannelList == NULL )
849 {
850 smsLog( pMac, LOGP, FL("vos_mem_malloc failed") );
851 return;
852 }
853#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800854 smsLog( pMac, LOGE, FL("Allocated memory for ChannelList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700855#endif
856
857 if ( pBeaconReq->channelInfo.channelNum != 255 )
858 {
859#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800860 smsLog( pMac, LOGE, "channel == %d ", pBeaconReq->channelInfo.channelNum );
Jeff Johnson295189b2012-06-20 16:38:30 -0700861#endif
862 if(csrRoamIsChannelValid( pMac, pBeaconReq->channelInfo.channelNum ))
863 pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->channelList.numOfChannels++] = pBeaconReq->channelInfo.channelNum;
864#if defined WLAN_VOWIFI_DEBUG
865 else
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800866 smsLog( pMac, LOGE, "is Invalid channel, Ignoring this channel" );
Jeff Johnson295189b2012-06-20 16:38:30 -0700867#endif
868 }
869
870 for ( i = 0 ; i < pBeaconReq->channelList.numChannels; i++ )
871 {
872 if(csrRoamIsChannelValid( pMac, pBeaconReq->channelList.channelNumber[i] ))
873 {
874 pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->channelList.numOfChannels] = pBeaconReq->channelList.channelNumber[i];
875 pSmeRrmContext->channelList.numOfChannels++;
876 }
877 }
878 }
879
880 //Copy session bssid
881 vos_mem_copy( pSmeRrmContext->sessionBssId, pBeaconReq->bssId, sizeof(tSirMacAddr) );
882
883 //copy measurement bssid
884 vos_mem_copy( pSmeRrmContext->bssId, pBeaconReq->macaddrBssid, sizeof(tSirMacAddr) );
885
886 //Copy ssid
887 vos_mem_copy( &pSmeRrmContext->ssId, &pBeaconReq->ssId, sizeof(tAniSSID) );
888
889 pSmeRrmContext->token = pBeaconReq->uDialogToken;
890 pSmeRrmContext->regClass = pBeaconReq->channelInfo.regulatoryClass;
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 pSmeRrmContext->randnIntvl = VOS_MAX( pBeaconReq->randomizationInterval, pSmeRrmContext->rrmConfig.maxRandnInterval );
892 pSmeRrmContext->currentIndex = 0;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800893 pSmeRrmContext->msgSource = pBeaconReq->msgSource;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800894 vos_mem_copy((tANI_U8*)&pSmeRrmContext->measMode, (tANI_U8*)&pBeaconReq->fMeasurementtype, SIR_ESE_MAX_MEAS_IE_REQS);
895 vos_mem_copy((tANI_U8*)&pSmeRrmContext->duration, (tANI_U8*)&pBeaconReq->measurementDuration, SIR_ESE_MAX_MEAS_IE_REQS);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800897 sme_RrmIssueScanReq( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700898
899 return;
900}
901
902/*--------------------------------------------------------------------------
903 \brief sme_RrmNeighborReportRequest() - This is API can be used to trigger a
904 Neighbor report from the peer.
905
906 \param sessionId - session identifier on which the request should be made.
907 \param pNeighborReq - a pointer to a neighbor report request.
908
909 \return eHAL_STATUS_SUCCESS - Validation is successful.
910
911 \sa
912
913 --------------------------------------------------------------------------*/
914VOS_STATUS sme_RrmNeighborReportRequest(tpAniSirGlobal pMac, tANI_U8 sessionId,
915 tpRrmNeighborReq pNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
916{
917 eHalStatus status = eHAL_STATUS_SUCCESS;
918 tpSirNeighborReportReqInd pMsg;
919 tCsrRoamSession *pSession;
920
921#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800922 smsLog( pMac, LOGE, FL("Request to send Neighbor report request received "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700923#endif
924 if( !CSR_IS_SESSION_VALID( pMac, sessionId ) )
925 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800926 smsLog( pMac, LOGE, FL("Invalid session %d"), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 return VOS_STATUS_E_INVAL;
928 }
929 pSession = CSR_GET_SESSION( pMac, sessionId );
930
931 /* If already a report is pending, return failure */
932 if (eANI_BOOLEAN_TRUE == pMac->rrm.rrmSmeContext.neighborReqControlInfo.isNeighborRspPending)
933 {
934 smsLog( pMac, LOGE, FL("Neighbor request already pending.. Not allowed"));
935 return VOS_STATUS_E_AGAIN;
936 }
937
938 pMsg = vos_mem_malloc ( sizeof(tSirNeighborReportReqInd) );
939 if ( NULL == pMsg )
940 {
941 smsLog( pMac, LOGE, "Unable to allocate memory for Neighbor request");
942 return VOS_STATUS_E_NOMEM;
943 }
944
945
946 vos_mem_zero( pMsg, sizeof(tSirNeighborReportReqInd) );
947#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800948 smsLog( pMac, LOGE, FL(" Allocated memory for Neighbor request") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700949#endif
950
951 rrmLLPurgeNeighborCache(pMac, &pMac->rrm.rrmSmeContext.neighborReportCache);
952
953#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800954 smsLog( pMac, LOGE, FL("Purged the neighbor cache before sending Neighbor request: Status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700955#endif
956
957 pMsg->messageType = eWNI_SME_NEIGHBOR_REPORT_REQ_IND;
958 pMsg->length = sizeof( tSirNeighborReportReqInd );
959 vos_mem_copy( &pMsg->bssId, &pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
960 pMsg->noSSID = pNeighborReq->no_ssid;
961 vos_mem_copy( &pMsg->ucSSID, &pNeighborReq->ssid, sizeof(tSirMacSSid));
962
963 status = palSendMBMessage(pMac->hHdd, pMsg);
964 if( status != eHAL_STATUS_SUCCESS )
965 return VOS_STATUS_E_FAILURE;
966
967 /* Neighbor report request message sent successfully to PE. Now register the callbacks */
968 pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallback =
969 callbackInfo->neighborRspCallback;
970 pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallbackContext =
971 callbackInfo->neighborRspCallbackContext;
972 pMac->rrm.rrmSmeContext.neighborReqControlInfo.isNeighborRspPending = eANI_BOOLEAN_TRUE;
973
974 /* Start neighbor response wait timer now */
975 vos_timer_start(&pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspWaitTimer, callbackInfo->timeout);
976
977 return VOS_STATUS_SUCCESS;
978}
979
980/*--------------------------------------------------------------------------
981 \brief rrmCalculateNeighborAPRoamScore() - This API is called while handling
982 individual neighbor reports from the APs neighbor AP report to
983 calculate the cumulative roam score before storing it in neighbor
984 cache.
985
986 \param pNeighborReportDesc - Neighbor BSS Descriptor node for which roam score
987 should be calculated
988
989 \return void.
990--------------------------------------------------------------------------*/
991static void rrmCalculateNeighborAPRoamScore(tpAniSirGlobal pMac, tpRrmNeighborReportDesc pNeighborReportDesc)
992{
993 tpSirNeighborBssDescripton pNeighborBssDesc;
994 tANI_U32 roamScore = 0;
995
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700996 if (NULL == pNeighborReportDesc)
997 {
998 VOS_ASSERT(0);
999 return;
1000 }
1001 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1002 {
1003 VOS_ASSERT(0);
1004 return;
1005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001006
1007 pNeighborBssDesc = pNeighborReportDesc->pNeighborBssDescription;
1008
1009 if (pNeighborBssDesc->bssidInfo.rrmInfo.fMobilityDomain)
1010 {
1011 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_MOBILITY_DOMAIN;
1012 if (pNeighborBssDesc->bssidInfo.rrmInfo.fSameSecurityMode)
1013 {
1014 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_SECURITY;
1015 if (pNeighborBssDesc->bssidInfo.rrmInfo.fSameAuthenticator)
1016 {
1017 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_KEY_SCOPE;
1018 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapRadioMeasurement)
1019 {
1020 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_RRM;
1021 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapSpectrumMeasurement)
1022 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_SPECTRUM_MGMT;
1023 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapQos)
1024 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_QOS;
1025 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapApsd)
1026 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_APSD;
1027 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapDelayedBlockAck)
1028 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_DELAYED_BA;
1029 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapImmediateBlockAck)
1030 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_IMMEDIATE_BA;
1031 if (pNeighborBssDesc->bssidInfo.rrmInfo.fApPreauthReachable)
1032 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_REACHABILITY;
1033 }
1034 }
1035 }
1036 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001037#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 // It has come in the report so its the best score
1039 if (csrNeighborRoamIs11rAssoc(pMac) == FALSE)
1040 {
1041 // IAPP Route so lets make use of this info
1042 // save all AP, as the list does not come all the time
1043 // Save and reuse till the next AP List comes to us.
1044 // Even save our own MAC address. Will be useful next time around.
1045 roamScore += RRM_ROAM_SCORE_NEIGHBOR_IAPP_LIST;
1046 }
1047#endif
1048 pNeighborReportDesc->roamScore = roamScore;
1049
1050 return;
1051}
1052
1053/*--------------------------------------------------------------------------
1054 \brief rrmStoreNeighborRptByRoamScore() - This API is called to store a given
1055 Neighbor BSS descriptor to the neighbor cache. This function
1056 stores the neighbor BSS descriptors in such a way that descriptors
1057 are sorted by roamScore in descending order
1058
1059 \param pNeighborReportDesc - Neighbor BSS Descriptor node to be stored in cache
1060
1061 \return void.
1062--------------------------------------------------------------------------*/
1063void rrmStoreNeighborRptByRoamScore(tpAniSirGlobal pMac, tpRrmNeighborReportDesc pNeighborReportDesc)
1064{
1065 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1066 tListElem *pEntry;
1067 tRrmNeighborReportDesc *pTempNeighborReportDesc;
1068
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -07001069 if (NULL == pNeighborReportDesc)
1070 {
1071 VOS_ASSERT(0);
1072 return;
1073 }
1074 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1075 {
1076 VOS_ASSERT(0);
1077 return;
1078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001079
1080 if (csrLLIsListEmpty(&pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK))
1081 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001082 smsLog(pMac, LOGE, FL("Neighbor report cache is empty.. Adding a entry now"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 /* Neighbor list cache is empty. Insert this entry in the tail */
1084 csrLLInsertTail(&pSmeRrmContext->neighborReportCache, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1085 return;
1086 }
1087 else
1088 {
1089 /* Should store the neighbor BSS description in the order sorted by roamScore in descending
1090 order. APs with highest roamScore should be the 1st entry in the list */
1091 pEntry = csrLLPeekHead(&pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK);
1092 while (pEntry != NULL)
1093 {
1094 pTempNeighborReportDesc = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1095 if (pTempNeighborReportDesc->roamScore < pNeighborReportDesc->roamScore)
1096 break;
1097 pEntry = csrLLNext(&pSmeRrmContext->neighborReportCache, pEntry, LL_ACCESS_LOCK);
1098 }
1099
1100 if (pEntry)
1101 /* This BSS roamscore is better than something in the list. Insert this before that one */
1102 csrLLInsertEntry(&pSmeRrmContext->neighborReportCache, pEntry, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1103 else
1104 /* All the entries in the list has a better roam Score than this one. Insert this at the last */
1105 csrLLInsertTail(&pSmeRrmContext->neighborReportCache, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1106 }
1107 return;
1108}
1109
1110/*--------------------------------------------------------------------------
1111 \brief sme_RrmProcessNeighborReport() - This is called to process the Neighbor
1112 report received from PE.
1113
1114 \param pMsgBuf - a pointer to a buffer that maps to various structures base
1115 on the message type.
1116 The beginning of the buffer can always map to tSirSmeRsp.
1117
1118 \return eHAL_STATUS_SUCCESS - Validation is successful.
1119
1120 \sa
1121
1122 --------------------------------------------------------------------------*/
1123eHalStatus sme_RrmProcessNeighborReport(tpAniSirGlobal pMac, void *pMsgBuf)
1124{
1125 eHalStatus status = eHAL_STATUS_SUCCESS;
1126 tpSirNeighborReportInd pNeighborRpt = (tpSirNeighborReportInd) pMsgBuf;
1127 tpRrmNeighborReportDesc pNeighborReportDesc;
1128 tANI_U8 i = 0;
1129 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1130
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001131#ifdef FEATURE_WLAN_ESE
1132 // Clear the cache for ESE.
1133 if (csrNeighborRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 {
1135 rrmLLPurgeNeighborCache(pMac,
1136 &pMac->rrm.rrmSmeContext.neighborReportCache);
1137 }
1138#endif
1139
1140 for (i = 0; i < pNeighborRpt->numNeighborReports; i++)
1141 {
1142 pNeighborReportDesc = vos_mem_malloc(sizeof(tRrmNeighborReportDesc));
1143 if (NULL == pNeighborReportDesc)
1144 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001145 smsLog( pMac, LOGE, "Failed to allocate memory for RRM Neighbor report desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 status = eHAL_STATUS_FAILED_ALLOC;
1147 goto end;
1148
1149 }
1150
1151 vos_mem_zero(pNeighborReportDesc, sizeof(tRrmNeighborReportDesc));
1152 pNeighborReportDesc->pNeighborBssDescription = vos_mem_malloc(sizeof(tSirNeighborBssDescription));
1153 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1154 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001155 smsLog( pMac, LOGE, "Failed to allocate memory for RRM Neighbor report BSS Description");
Jeff Johnsonfb82ea52013-04-03 15:35:49 -07001156 vos_mem_free(pNeighborReportDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 status = eHAL_STATUS_FAILED_ALLOC;
1158 goto end;
1159 }
1160 vos_mem_zero(pNeighborReportDesc->pNeighborBssDescription, sizeof(tSirNeighborBssDescription));
1161 vos_mem_copy(pNeighborReportDesc->pNeighborBssDescription, &pNeighborRpt->sNeighborBssDescription[i],
1162 sizeof(tSirNeighborBssDescription));
1163
1164#if defined WLAN_VOWIFI_DEBUG
Arif Hussain24bafea2013-11-15 15:10:03 -08001165 smsLog( pMac, LOGE, "Received neighbor report with Neighbor BSSID: "MAC_ADDRESS_STR,
1166 MAC_ADDR_ARRAY(pNeighborRpt->sNeighborBssDescription[i].bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001167#endif
1168
1169 /* Calculate the roam score based on the BSS Capability in the BSSID Information and store it in Neighbor report Desc */
1170 rrmCalculateNeighborAPRoamScore(pMac, pNeighborReportDesc);
1171
1172 /* Store the Neighbor report Desc in the cache based on the roam score */
1173 if ( pNeighborReportDesc->roamScore > 0)
1174 {
1175 rrmStoreNeighborRptByRoamScore(pMac, pNeighborReportDesc);
1176 }
1177 else
1178 {
Arif Hussain24bafea2013-11-15 15:10:03 -08001179 smsLog(pMac, LOGE, FL("Roam score of BSSID "MAC_ADDRESS_STR" is 0, Ignoring.."),
1180 MAC_ADDR_ARRAY(pNeighborRpt->sNeighborBssDescription[i].bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001181
1182 vos_mem_free(pNeighborReportDesc->pNeighborBssDescription);
1183 vos_mem_free(pNeighborReportDesc);
1184 }
1185 }
1186end:
1187
1188 if (!csrLLCount(&pMac->rrm.rrmSmeContext.neighborReportCache))
1189 vosStatus = VOS_STATUS_E_FAILURE;
1190
1191 /* Received a report from AP. Indicate SUCCESS to the caller if there are some valid reports */
1192 rrmIndicateNeighborReportResult(pMac, vosStatus);
1193
1194 return status;
1195}
1196/*--------------------------------------------------------------------------
1197 \brief sme_RrmMsgProcessor() - sme_ProcessMsg() calls this function for the
1198 messages that are handled by SME RRM module.
1199
1200 \param pMac - Pointer to the global MAC parameter structure.
1201 \param msg_type - the type of msg passed by PE as defined in wniApi.h
1202 \param pMsgBuf - a pointer to a buffer that maps to various structures base
1203 on the message type.
1204 The beginning of the buffer can always map to tSirSmeRsp.
1205
1206 \return eHAL_STATUS_SUCCESS - Validation is successful.
1207
1208 \sa
1209
1210 --------------------------------------------------------------------------*/
1211eHalStatus sme_RrmMsgProcessor( tpAniSirGlobal pMac, v_U16_t msg_type,
1212 void *pMsgBuf)
1213{
1214 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001215 FL(" Msg = %d for RRM measurement") , msg_type );
Jeff Johnson295189b2012-06-20 16:38:30 -07001216
1217 //switch on the msg type & make the state transition accordingly
1218 switch(msg_type)
1219 {
1220 case eWNI_SME_NEIGHBOR_REPORT_IND:
1221 sme_RrmProcessNeighborReport( pMac, pMsgBuf );
1222 break;
1223
1224 case eWNI_SME_BEACON_REPORT_REQ_IND:
1225 sme_RrmProcessBeaconReportReqInd( pMac, pMsgBuf );
1226 break;
1227
1228 default:
1229 //err msg
1230 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001231 FL("sme_RrmMsgProcessor:unknown msg type = %d"), msg_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07001232
1233 break;
1234 }
1235
1236 return eHAL_STATUS_SUCCESS;
1237}
1238
1239/* ---------------------------------------------------------------------------
1240
1241 \fn rrmIterMeasTimerHandle
1242
1243 \brief Timer handler to handlet the timeout condition when a specific BT
1244
1245 stop event does not come back, in which case to restore back the
1246
1247 heartbeat timer.
1248
1249 \param pMac - The handle returned by macOpen.
1250
1251 \return VOID
1252
1253 ---------------------------------------------------------------------------*/
1254
1255void rrmIterMeasTimerHandle( v_PVOID_t userData )
1256{
1257 tpAniSirGlobal pMac = (tpAniSirGlobal) userData;
1258#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001259 smsLog( pMac, LOGE, "Randomization timer expired...send on next channel ");
Jeff Johnson295189b2012-06-20 16:38:30 -07001260#endif
1261 //Issue a scan req for next channel.
1262 sme_RrmIssueScanReq( pMac );
1263}
1264
1265/* ---------------------------------------------------------------------------
1266
1267 \fn rrmNeighborRspTimeoutHandler
1268
1269 \brief Timer handler to handle the timeout condition when a neighbor request is sent
1270 and no neighbor response is received from the AP
1271
1272 \param pMac - The handle returned by macOpen.
1273
1274 \return VOID
1275
1276---------------------------------------------------------------------------*/
1277
1278void rrmNeighborRspTimeoutHandler
1279( v_PVOID_t userData )
1280{
1281 tpAniSirGlobal pMac = (tpAniSirGlobal) userData;
1282#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001283 smsLog( pMac, LOGE, "Neighbor Response timed out ");
Jeff Johnson295189b2012-06-20 16:38:30 -07001284#endif
1285 rrmIndicateNeighborReportResult(pMac, VOS_STATUS_E_FAILURE);
1286 return;
1287}
1288
1289/* ---------------------------------------------------------------------------
1290
1291 \fn rrmOpen
1292
1293 \brief
1294
1295 \param pMac - The handle returned by macOpen.
1296
1297 \return VOS_STATUS
1298
1299 VOS_STATUS_E_FAILURE success
1300
1301 VOS_STATUS_SUCCESS failure
1302
1303 ---------------------------------------------------------------------------*/
1304
1305VOS_STATUS rrmOpen (tpAniSirGlobal pMac)
1306
1307{
1308
1309 VOS_STATUS vosStatus;
1310 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1311 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1312
1313 pSmeRrmContext->rrmConfig.maxRandnInterval = 50; //ms
1314
1315 vosStatus = vos_timer_init( &pSmeRrmContext->IterMeasTimer,
1316
1317 VOS_TIMER_TYPE_SW,
1318
1319 rrmIterMeasTimerHandle,
1320
1321 (void*) pMac);
1322
1323 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
1324
1325 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to init timer");
1326
1327 return VOS_STATUS_E_FAILURE;
1328 }
1329
1330 vosStatus = vos_timer_init( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer,
1331
1332 VOS_TIMER_TYPE_SW,
1333
1334 rrmNeighborRspTimeoutHandler,
1335
1336 (void*) pMac);
1337
1338 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
1339
1340 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to init timer");
1341
1342 return VOS_STATUS_E_FAILURE;
1343 }
1344
1345 pSmeRrmContext->neighborReqControlInfo.isNeighborRspPending = eANI_BOOLEAN_FALSE;
1346
1347 halStatus = csrLLOpen(pMac->hHdd, &pSmeRrmContext->neighborReportCache);
1348 if (eHAL_STATUS_SUCCESS != halStatus)
1349 {
1350 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to open neighbor cache result");
1351 return VOS_STATUS_E_FAILURE;
1352 }
1353
1354 return VOS_STATUS_SUCCESS;
1355}
1356
1357
1358/* ---------------------------------------------------------------------------
1359
1360 \fn rrmClose
1361
1362 \brief
1363
1364 \param pMac - The handle returned by macOpen.
1365
1366 \return VOS_STATUS
1367
1368 VOS_STATUS_E_FAILURE success
1369
1370 VOS_STATUS_SUCCESS failure
1371
1372 ---------------------------------------------------------------------------*/
1373
1374VOS_STATUS rrmClose (tpAniSirGlobal pMac)
1375
1376{
1377
1378 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1379 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1380
1381 if( VOS_TIMER_STATE_RUNNING == vos_timer_getCurrentState( &pSmeRrmContext->IterMeasTimer ) )
1382 {
1383 vosStatus = vos_timer_stop( &pSmeRrmContext->IterMeasTimer );
1384 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001385 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("Timer stop fail") );
1387 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001389
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001390 vosStatus = vos_timer_destroy( &pSmeRrmContext->IterMeasTimer );
1391 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1392 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("Fail to destroy timer") );
1395
1396 }
1397
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001398 if( VOS_TIMER_STATE_RUNNING ==
1399 vos_timer_getCurrentState( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer ) )
1400 {
1401 vosStatus = vos_timer_stop( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer );
1402 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1403 {
1404 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, FL("Timer stop fail") );
1405 }
1406 }
1407
1408 vosStatus = vos_timer_destroy( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer );
1409 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1410 {
1411 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, FL("Fail to destroy timer") );
1412
1413 }
1414
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 rrmLLPurgeNeighborCache(pMac, &pSmeRrmContext->neighborReportCache);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001416
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 csrLLClose(&pSmeRrmContext->neighborReportCache);
1418
1419 return vosStatus;
1420
1421}
1422
1423
1424
1425
1426/* ---------------------------------------------------------------------------
1427
1428 \fn rrmReady
1429
1430 \brief fn
1431
1432 \param pMac - The handle returned by macOpen.
1433
1434 \return VOS_STATUS
1435
1436 ---------------------------------------------------------------------------*/
1437
1438VOS_STATUS rrmReady (tpAniSirGlobal pMac)
1439
1440{
1441
1442 return VOS_STATUS_SUCCESS;
1443}
1444
1445/* ---------------------------------------------------------------------------
1446
1447 \fn rrmChangeDefaultConfigParam
1448 \brief fn
1449
1450 \param pMac - The handle returned by macOpen.
1451 \param pRrmConfig - pointer to new rrm configs.
1452
1453 \return VOS_STATUS
1454
1455 ---------------------------------------------------------------------------*/
1456VOS_STATUS rrmChangeDefaultConfigParam(tpAniSirGlobal pMac, tpRrmConfigParam pRrmConfig)
1457{
1458 vos_mem_copy( &pMac->rrm.rrmSmeContext.rrmConfig, pRrmConfig, sizeof( tRrmConfigParam ) );
1459
1460 return VOS_STATUS_SUCCESS;
1461}
1462
1463/* ---------------------------------------------------------------------------
1464
1465 \fn smeRrmGetFirstBssEntryFromNeighborCache()
1466
1467 \brief This function returns the first entry from the neighbor cache to the caller
1468
1469 \param pMac - The handle returned by macOpen.
1470
1471 \return VOID
1472
1473---------------------------------------------------------------------------*/
1474tRrmNeighborReportDesc* smeRrmGetFirstBssEntryFromNeighborCache( tpAniSirGlobal pMac)
1475{
1476 tListElem *pEntry;
1477 tRrmNeighborReportDesc *pTempBssEntry = NULL;
1478 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1479
1480
1481 pEntry = csrLLPeekHead( &pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK );
1482
1483 if(!pEntry || !csrLLCount(&pSmeRrmContext->neighborReportCache))
1484 {
1485 //list empty
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001486 smsLog(pMac, LOGW, FL("List empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 return NULL;
1488 }
1489
1490 pTempBssEntry = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1491
1492 return pTempBssEntry;
1493}
1494
1495/* ---------------------------------------------------------------------------
1496
1497 \fn smeRrmGetNextBssEntryFromNeighborCache()
1498
1499 \brief This function returns the entry next to the given entry from the
1500 neighbor cache to the caller
1501
1502 \param pMac - The handle returned by macOpen.
1503
1504 \return VOID
1505
1506---------------------------------------------------------------------------*/
1507tRrmNeighborReportDesc* smeRrmGetNextBssEntryFromNeighborCache( tpAniSirGlobal pMac,
1508 tpRrmNeighborReportDesc pBssEntry)
1509{
1510 tListElem *pEntry;
1511 tRrmNeighborReportDesc *pTempBssEntry = NULL;
1512
1513 pEntry = csrLLNext(&pMac->rrm.rrmSmeContext.neighborReportCache, &pBssEntry->List, LL_ACCESS_LOCK);
1514
1515 if(!pEntry)
1516 {
1517 //list empty
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001518 smsLog(pMac, LOGW, FL("List empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 return NULL;
1520 }
1521
1522 pTempBssEntry = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1523
1524 return pTempBssEntry;
1525}
1526
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001527#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
1528void csrEseSendAdjacentApRepMsg(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -07001529{
1530 tpSirAdjacentApRepInd pAdjRep;
1531 tANI_U16 length;
1532 tANI_U32 roamTS2;
1533
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001534 smsLog( pMac, LOG1, "Adjacent AP Report Msg to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07001535
1536 length = sizeof(tSirAdjacentApRepInd );
1537 pAdjRep = vos_mem_malloc ( length );
1538
1539 if ( NULL == pAdjRep )
1540 {
1541 smsLog( pMac, LOGP, "Unable to allocate memory for Adjacent AP report");
1542 return;
1543 }
1544
1545 vos_mem_zero( pAdjRep, length );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001546 pAdjRep->messageType = eWNI_SME_ESE_ADJACENT_AP_REPORT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 pAdjRep->length = length;
1548 pAdjRep->channelNum = pSession->prevOpChannel;
1549 vos_mem_copy( pAdjRep->bssid, &pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
1550 vos_mem_copy( pAdjRep->prevApMacAddr, &pSession->prevApBssid, sizeof(tSirMacAddr) );
1551 vos_mem_copy( &pAdjRep->prevApSSID, &pSession->prevApSSID, sizeof(tSirMacSSid) );
1552 roamTS2 = vos_timer_get_system_time();
1553 pAdjRep->tsmRoamdelay = roamTS2 - pSession->roamTS1;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001554 pAdjRep->roamReason =SIR_ESE_ASSOC_REASON_UNSPECIFIED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 pAdjRep->clientDissSecs =(pAdjRep->tsmRoamdelay/1000);
1556
1557 palSendMBMessage(pMac->hHdd, pAdjRep);
1558
1559 return;
1560}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001561#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001562#endif