blob: 9182640be1462c03f43d2cb4c7ba805f20a05b9f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Padma, Santhosh Kumard5421562018-01-24 19:57:40 +05302 * Copyright (c) 2012-2014, 2016,2018 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 \file sme_Rrm.c
31
32 \brief implementation for SME RRM APIs
33
Kiet Lamaa8e15a2014-02-11 23:30:06 -080034
Jeff Johnson295189b2012-06-20 16:38:30 -070035 ========================================================================*/
36
37/* $Header$ */
38
39#if defined WLAN_FEATURE_VOWIFI
40/*--------------------------------------------------------------------------
41 Include Files
42 ------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "aniGlobal.h"
44#include "smeInside.h"
45#include "sme_Api.h"
46#include "smsDebug.h"
47#include "cfgApi.h"
48
49#ifdef FEATURE_WLAN_DIAG_SUPPORT
50#include "vos_diag_core_event.h"
51#include "vos_diag_core_log.h"
52#endif /* FEATURE_WLAN_DIAG_SUPPORT */
53
54#include "csrInsideApi.h"
55
56#include "rrmGlobal.h"
57
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080058#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
59#include "csrEse.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070060#endif
61
62/* Roam score for a neighbor AP will be calculated based on the below definitions.
63 The calculated roam score will be used to select the roamable candidate from neighbor AP list */
64#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_REACHABILITY 0 /* When we support 11r over the DS, this should have a non-zero value */
65#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_SECURITY 10
66#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_KEY_SCOPE 20
67#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_SPECTRUM_MGMT 0 /* Not used */
68#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_QOS 5
69#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_APSD 3
70#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_RRM 8
71#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_DELAYED_BA 0 /* We dont support delayed BA */
72#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_IMMEDIATE_BA 3
73#define RRM_ROAM_SCORE_NEIGHBOR_REPORT_MOBILITY_DOMAIN 30
74
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080075#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070076#define RRM_ROAM_SCORE_NEIGHBOR_IAPP_LIST 30
77#endif
Padma, Santhosh Kumarc7c22552016-03-21 13:07:52 +053078
79v_TIME_t RRM_scan_timer;
80
Jeff Johnson295189b2012-06-20 16:38:30 -070081/**---------------------------------------------------------------------------
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;
Padma, Santhosh Kumarf21a0d92015-11-02 12:41:06 +0530233 vos_mem_zero(pBeaconRep->pBssDescription[msgCounter],
234 ie_len+sizeof(tSirBssDescription));
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530235 vos_mem_copy( pBeaconRep->pBssDescription[msgCounter],
236 pBssDesc,
237 sizeof(tSirBssDescription) );
238 vos_mem_copy( &pBeaconRep->pBssDescription[msgCounter]->ieFields[0],
239 pBssDesc->ieFields, ie_len );
240 smsLog( pMac, LOG1,
Arif Hussain24bafea2013-11-15 15:10:03 -0800241 "...RRM Result Bssid = "MAC_ADDRESS_STR" chan= %d, rssi = -%d",
242 MAC_ADDR_ARRAY(pBeaconRep->pBssDescription[msgCounter]->bssId),
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530243 pBeaconRep->pBssDescription[msgCounter]->channelId,
244 pBeaconRep->pBssDescription[msgCounter]->rssi * (-1));
Jeff Johnson295189b2012-06-20 16:38:30 -0700245
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530246 pBeaconRep->numBssDesc++;
Jeff Johnson295189b2012-06-20 16:38:30 -0700247
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800248 if (++msgCounter >= SIR_BCN_REPORT_MAX_BSS_DESC)
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530249 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530251 pCurResult = pResultArr[bssCounter + msgCounter];
252 }
253 else
254 {
255 pCurResult = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 break;
257 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700258 }
259
260 bssCounter+=msgCounter;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530261 if (!pResultArr || (pCurResult == NULL) || (bssCounter >= bss_count))
262 {
263 pCurResult = NULL;
264 smsLog(pMac, LOG1,
265 "Reached to the max/last BSS in pCurResult list");
266 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 else
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530268 {
269 pCurResult = pResultArr[bssCounter];
270 smsLog(pMac, LOG1,
271 "Move to the next BSS set in pCurResult list");
272 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
274 pBeaconRep->fMeasureDone = (pCurResult)?false:measurementDone;
275
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530276 smsLog(pMac, LOG1,
277 "SME Sending BcnRepXmit to PE numBss %d msgCounter %d bssCounter %d",
278 pBeaconRep->numBssDesc, msgCounter, bssCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
Jeff Johnson0282cf02013-04-03 17:30:03 -0700280 status = palSendMBMessage(pMac->hHdd, pBeaconRep);
Jeff Johnson295189b2012-06-20 16:38:30 -0700281
282 } while (pCurResult);
283
284 return status;
285}
286
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800287#if defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800288/**---------------------------------------------------------------------------
289
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800290 \brief sme_EseSendBeaconReqScanResults()
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800291
292 This function sends up the scan results received as a part of
293 beacon request scanning.
294 This function is called after receiving the scan results per channel
295 Due to the limitation on the size of the IWEVCUSTOM buffer, we send 3 BSSIDs of
296 beacon report information in one custom event;
297
298 \param - pMac - Pointer to the Hal Handle.
299 - sessionId - Session id
300 - channel - scan results belongs to this channel
301 - pResultArr - scan result.
302 - measurementDone - flag to indicate that the measurement is done.
303 - bss_count - number of bss found
304 \return - 0 for success, non zero for failure
305
306 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800307static eHalStatus sme_EseSendBeaconReqScanResults(tpAniSirGlobal pMac,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800308 tANI_U32 sessionId,
309 tANI_U8 channel,
310 tCsrScanResultInfo **pResultArr,
311 tANI_U8 measurementDone,
312 tANI_U8 bss_count)
313{
314 eHalStatus status = eHAL_STATUS_FAILURE;
Varun Reddy Yeturucf02bc22013-12-06 18:18:50 -0800315 tSirRetStatus fillIeStatus;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800316 tpSirBssDescription pBssDesc = NULL;
317 tANI_U32 ie_len = 0;
318 tANI_U32 outIeLen = 0;
319 tANI_U8 bssCounter = 0;
320 tCsrScanResultInfo *pCurResult = NULL;
321 tANI_U8 msgCounter = 0;
322 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
323 tCsrRoamInfo roamInfo;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800324 tSirEseBcnReportRsp bcnReport;
325 tpSirEseBcnReportRsp pBcnReport = &bcnReport;
326 tpCsrEseBeaconReqParams pCurMeasReqIe = NULL;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800327 tANI_U8 i = 0;
328
329 if (NULL == pSmeRrmContext)
330 {
331 smsLog( pMac, LOGE, "pSmeRrmContext is NULL");
332 return eHAL_STATUS_FAILURE;
333 }
334
335 if (NULL == pResultArr && !measurementDone)
336 {
337 smsLog( pMac, LOGE, "Beacon report xmit Ind to HDD Failed");
338 return eHAL_STATUS_FAILURE;
339 }
340
341 if (pResultArr)
342 pCurResult=pResultArr[bssCounter];
343
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800344 vos_mem_zero(&bcnReport, sizeof(tSirEseBcnReportRsp));
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800345 do
346 {
347 pCurMeasReqIe = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800348 for (i = 0; i < pSmeRrmContext->eseBcnReqInfo.numBcnReqIe; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800349 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800350 if(pSmeRrmContext->eseBcnReqInfo.bcnReq[i].channel == channel)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800351 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800352 pCurMeasReqIe = &pSmeRrmContext->eseBcnReqInfo.bcnReq[i];
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800353 break;
354 }
355 }
Padma, Santhosh Kumar795a3b02014-01-17 21:28:26 +0530356 if(NULL != pCurMeasReqIe)
357 pBcnReport->measurementToken = pCurMeasReqIe->measurementToken;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800358 smsLog( pMac, LOG1, "Channel(%d) MeasToken(%d)", channel, pBcnReport->measurementToken);
359
360 msgCounter=0;
361 while (pCurResult)
362 {
363 pBssDesc = &pCurResult->BssDescriptor;
364 if (NULL != pBssDesc)
365 {
366 ie_len = GET_IE_LEN_IN_BSS( pBssDesc->length );
367 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.ChanNum = pBssDesc->channelId;
368 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.Spare = 0;
Padma, Santhosh Kumar795a3b02014-01-17 21:28:26 +0530369 if(NULL != pCurMeasReqIe)
370 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.MeasDuration = pCurMeasReqIe->measurementDuration;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800371 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.PhyType = pBssDesc->nwType;
372 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.RecvSigPower = pBssDesc->rssi;
373 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.ParentTsf = pBssDesc->parentTSF;
374 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.TargetTsf[0] = pBssDesc->timeStamp[0];
375 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.TargetTsf[1] = pBssDesc->timeStamp[1];
376 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.BcnInterval = pBssDesc->beaconInterval;
377 pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.CapabilityInfo = pBssDesc->capabilityInfo;
378 vos_mem_copy(pBcnReport->bcnRepBssInfo[msgCounter].bcnReportFields.Bssid,
379 pBssDesc->bssId, sizeof(tSirMacAddr));
380
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800381 fillIeStatus = sirFillBeaconMandatoryIEforEseBcnReport(pMac,
Varun Reddy Yeturucf02bc22013-12-06 18:18:50 -0800382 (tANI_U8 *)pBssDesc->ieFields,
383 ie_len,
384 &(pBcnReport->bcnRepBssInfo[msgCounter].pBuf),
385 &outIeLen);
386 if (eSIR_FAILURE == fillIeStatus)
387 {
388 continue;
389 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800390 pBcnReport->bcnRepBssInfo[msgCounter].ieLen = outIeLen;
391
Arif Hussaina7c8e412013-11-20 11:06:42 -0800392 smsLog( pMac, LOG1,"Bssid("MAC_ADDRESS_STR") Channel=%d Rssi=%d",
393 MAC_ADDR_ARRAY(pBssDesc->bssId),
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800394 pBssDesc->channelId, (-1) * pBssDesc->rssi);
395
396 pBcnReport->numBss++;
397
398 if (++msgCounter >= SIR_BCN_REPORT_MAX_BSS_DESC)
399 break;
400
401 pCurResult = pResultArr[msgCounter];
402 }
403 else
404 {
405 pCurResult = NULL;
406 break;
407 }
408 }
409
410 bssCounter += msgCounter;
411 if (!pResultArr || !pCurResult || (bssCounter >= SIR_BCN_REPORT_MAX_BSS_DESC))
412 {
413 pCurResult = NULL;
414 smsLog(pMac, LOGE,
415 "Reached to the max/last BSS in pCurResult list");
416 }
417 else
418 {
419 pCurResult = pResultArr[bssCounter];
420 smsLog(pMac, LOGE,
421 "Move to the next BSS set in pCurResult list");
422 }
423
424 pBcnReport->flag = (measurementDone << 1)|((pCurResult)?true:false);
425
426 smsLog(pMac, LOG1, "SME Sending BcnRep to HDD numBss(%d)"
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800427 " msgCounter(%d) bssCounter(%d) flag(%d)",
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800428 pBcnReport->numBss, msgCounter, bssCounter, pBcnReport->flag);
429
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800430 roamInfo.pEseBcnReportRsp = pBcnReport;
431 status = csrRoamCallCallback(pMac, sessionId, &roamInfo,
432 0, eCSR_ROAM_ESE_BCN_REPORT_IND, 0);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800433
434 /* Free the memory allocated to IE */
435 for (i = 0; i < msgCounter; i++)
436 {
437 if (pBcnReport->bcnRepBssInfo[i].pBuf)
438 vos_mem_free(pBcnReport->bcnRepBssInfo[i].pBuf);
439 }
440 } while (pCurResult);
441 return status;
442}
443
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800444#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800445
Jeff Johnson295189b2012-06-20 16:38:30 -0700446/**---------------------------------------------------------------------------
447
448 \brief sme_RrmSendScanRequest() -
449
450 This function is called to get the scan result from CSR and send the beacon report
451 xmit ind message to PE.
452
453 \param - pMac - Pointer to the Hal Handle.
454 - num_chan - number of channels.
455 - channel list - list of channels to fetch the result from.
456 - measurementDone - flag to indicate that the measurement is done.
457 \return - 0 for success, non zero for failure
458
459 --------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530460static eHalStatus sme_RrmSendScanResult( tpAniSirGlobal pMac,
461 tANI_U8 num_chan,
462 tANI_U8* chanList,
463 tANI_U8 measurementDone )
Jeff Johnson295189b2012-06-20 16:38:30 -0700464{
465 tCsrScanResultFilter filter;
466 tScanResultHandle pResult;
467 tCsrScanResultInfo *pScanResult, *pNextResult;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800468 tCsrScanResultInfo *pScanResultsArr[SIR_BCN_REPORT_MAX_BSS_DESC];
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 eHalStatus status;
470 tANI_U8 counter=0;
471 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
472 tANI_U32 sessionId;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +0530473 tCsrRoamInfo *roam_info;
Jeff Johnson295189b2012-06-20 16:38:30 -0700474
475#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800476 smsLog( pMac, LOGE, "Send scan result to PE ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700477#endif
478
479 vos_mem_zero( &filter, sizeof(filter) );
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800480 vos_mem_zero( pScanResultsArr, sizeof(pNextResult)*SIR_BCN_REPORT_MAX_BSS_DESC );
Jeff Johnson295189b2012-06-20 16:38:30 -0700481
482 filter.BSSIDs.numOfBSSIDs = 1;
483 filter.BSSIDs.bssid = &pSmeRrmContext->bssId;
484
485 if( pSmeRrmContext->ssId.length )
486 {
487 filter.SSIDs.SSIDList =( tCsrSSIDInfo *)vos_mem_malloc(sizeof(tCsrSSIDInfo));
488 if( filter.SSIDs.SSIDList == NULL )
489 {
490 smsLog( pMac, LOGP, FL("vos_mem_malloc failed:") );
491 return eHAL_STATUS_FAILURE;
492 }
493#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800494 smsLog( pMac, LOGE, FL("Allocated memory for SSIDList"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700495#endif
496 vos_mem_zero( filter.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) );
497
498 filter.SSIDs.SSIDList->SSID.length = pSmeRrmContext->ssId.length;
499 vos_mem_copy(filter.SSIDs.SSIDList->SSID.ssId, pSmeRrmContext->ssId.ssId, pSmeRrmContext->ssId.length);
500 filter.SSIDs.numOfSSIDs = 1;
501 }
502 else
503 {
504 filter.SSIDs.numOfSSIDs = 0;
505 }
506
507 filter.ChannelInfo.numOfChannels = num_chan;
508 filter.ChannelInfo.ChannelList = chanList;
509
510 filter.fMeasurement = TRUE;
511
512 csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid*)pSmeRrmContext->sessionBssId, &sessionId );
513 status = sme_ScanGetResult(pMac, (tANI_U8)sessionId, &filter, &pResult);
514
515 if( filter.SSIDs.SSIDList )
516 {
517 //Free the memory allocated for SSIDList.
518 vos_mem_free( filter.SSIDs.SSIDList );
519#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800520 smsLog( pMac, LOGE, FL("Free memory for SSIDList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700521#endif
522 }
523
Padma, Santhosh Kumare4f9ade2016-03-21 13:34:49 +0530524 smsLog(pMac, LOG1, FL("RRM Measurement Done %d"), measurementDone);
525
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 if (NULL == pResult)
527 {
528 // no scan results
529 //
530 // Spec. doesnt say anything about such condition.
531 // Since section 7.4.6.2 (IEEE802.11k-2008) says-rrm report frame should contain
532 // one or more report IEs. It probably means dont send any respose if no matching
533 // BSS found. Moreover, there is no flag or field in measurement report IE(7.3.2.22)
534 // OR beacon report IE(7.3.2.22.6) that can be set to indicate no BSS found on a given channel.
535 //
536 // If we finished measurement on all the channels, we still need to
537 // send a xmit indication with moreToFollow set to MEASURMENT_DONE
538 // so that PE can clean any context allocated.
539 if( measurementDone )
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800540 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800541#if defined(FEATURE_WLAN_ESE_UPLOAD)
542 if (eRRM_MSG_SOURCE_ESE_UPLOAD == pSmeRrmContext->msgSource)
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800543 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800544 status = sme_EseSendBeaconReqScanResults(pMac,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800545 sessionId,
546 chanList[0],
547 NULL,
548 measurementDone,
549 0);
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800550 }
551 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800552#endif /*FEATURE_WLAN_ESE_UPLOAD*/
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800553 status = sme_RrmSendBeaconReportXmitInd( pMac, NULL, measurementDone, 0);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800554 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 return status;
556 }
557
558 pScanResult = sme_ScanResultGetFirst(pMac, pResult);
559
560 if( NULL == pScanResult && measurementDone )
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800561 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800562#if defined(FEATURE_WLAN_ESE_UPLOAD)
563 if (eRRM_MSG_SOURCE_ESE_UPLOAD == pSmeRrmContext->msgSource)
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800564 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800565 status = sme_EseSendBeaconReqScanResults(pMac,
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800566 sessionId,
567 chanList[0],
568 NULL,
569 measurementDone,
570 0);
571 }
572 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800573#endif /*FEATURE_WLAN_ESE_UPLOAD*/
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800574 status = sme_RrmSendBeaconReportXmitInd( pMac, NULL, measurementDone, 0 );
575 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700576
577 counter=0;
578 while (pScanResult)
579 {
580 pNextResult = sme_ScanResultGetNext(pMac, pResult);
Padma, Santhosh Kumar4a6c1882016-03-21 13:21:48 +0530581 smsLog(pMac, LOG1, "Scan res timer:%lu, rrm scan timer:%lu",
582 pScanResult->timer, RRM_scan_timer);
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +0530583 if (pScanResult->timer >= RRM_scan_timer) {
584 roam_info = vos_mem_malloc(sizeof(*roam_info));
585 if (NULL == roam_info) {
586 smsLog(pMac, LOGW, FL("vos_mem_malloc failed:"));
587 status = eHAL_STATUS_FAILED_ALLOC;
588 goto rrm_send_scan_results_done;
589 }
590 vos_mem_zero(roam_info, sizeof(*roam_info));
591 roam_info->pBssDesc = &pScanResult->BssDescriptor;
592 csrRoamCallCallback(pMac, sessionId, roam_info, 0,
593 eCSR_ROAM_UPDATE_SCAN_RESULT, eCSR_ROAM_RESULT_NONE);
594 vos_mem_free(roam_info);
595 pScanResultsArr[counter++] = pScanResult;
596 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 pScanResult = pNextResult; //sme_ScanResultGetNext(hHal, pResult);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800598 if (counter >= SIR_BCN_REPORT_MAX_BSS_DESC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 break;
600 }
601
Padma, Santhosh Kumar4a6c1882016-03-21 13:21:48 +0530602 smsLog(pMac, LOG1, " Number of BSS Desc with RRM Scan %d ", counter);
603 /*
604 * The beacon report should be sent whether the counter is zero or non-zero.
605 * There might be a few scan results in the cache but not actually are a
606 * result of this scan. During that scenario, the counter will be zero.
607 * The report should be sent and LIM will further cleanup the RRM to
608 * accept the further incoming requests
609 * In case the counter is Zero, the pScanResultsArr will be NULL.
610 * The next level routine does a check for the measurementDone to determine
611 * whether to send a report or not.
612 */
613
Padma, Santhosh Kumare4f9ade2016-03-21 13:34:49 +0530614 if (counter || measurementDone) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800615#if defined(FEATURE_WLAN_ESE_UPLOAD)
Padma, Santhosh Kumare4f9ade2016-03-21 13:34:49 +0530616 if (eRRM_MSG_SOURCE_ESE_UPLOAD == pSmeRrmContext->msgSource)
617 {
618 status = sme_EseSendBeaconReqScanResults(pMac,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800619 sessionId,
620 chanList[0],
621 pScanResultsArr,
622 measurementDone,
623 counter);
Padma, Santhosh Kumare4f9ade2016-03-21 13:34:49 +0530624 }
625 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800626#endif /*FEATURE_WLAN_ESE_UPLOAD*/
Padma, Santhosh Kumare4f9ade2016-03-21 13:34:49 +0530627 status = sme_RrmSendBeaconReportXmitInd( pMac,
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530628 pScanResultsArr,
629 measurementDone,
630 counter);
Padma, Santhosh Kumare4f9ade2016-03-21 13:34:49 +0530631 }
Padma, Santhosh Kumar4a6c1882016-03-21 13:21:48 +0530632
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +0530633rrm_send_scan_results_done:
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 sme_ScanResultPurge(pMac, pResult);
635
636 return status;
637}
638/**---------------------------------------------------------------------------
639
640 \brief sme_RrmScanRequestCallback() -
641
642 The sme module calls this callback function once it finish the scan request
643 and this function send the beacon report xmit to PE and starts a timer of
644 random interval to issue next request.
645
646 \param - halHandle - Pointer to the Hal Handle.
647 - pContext - Pointer to the data context.
648 - scanId - Scan ID.
649 - status - CSR Status.
650 \return - 0 for success, non zero for failure
651
652 --------------------------------------------------------------------------*/
653
654static eHalStatus sme_RrmScanRequestCallback(tHalHandle halHandle, void *pContext,
655 tANI_U32 scanId, eCsrScanStatus status)
656{
657
658 tANI_U16 interval;
659 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
660 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
661 tANI_U32 time_tick;
662
663
664
665#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800666 smsLog( pMac, LOGE, "Scan Request callback ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700667#endif
668 //if any more channels are pending, start a timer of a random value within randomization interval.
669 //
670 //
671 if( (pSmeRrmContext->currentIndex + 1) < pSmeRrmContext->channelList.numOfChannels )
672 {
673 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], false );
674
675 pSmeRrmContext->currentIndex++; //Advance the current index.
676 //start the timer to issue next request.
677 //From timer tick get a random number within 10ms and max randmization interval.
678 time_tick = vos_timer_get_system_ticks();
679 interval = time_tick % (pSmeRrmContext->randnIntvl - 10 + 1) + 10;
680
681#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800682 smsLog( pMac, LOGE, "Set timer for interval %d ", interval);
Jeff Johnson295189b2012-06-20 16:38:30 -0700683#endif
684 vos_timer_start( &pSmeRrmContext->IterMeasTimer, interval );
685
686 }
687 else
688 {
689 //Done with the measurement. Clean up all context and send a message to PE with measurement done flag set.
690 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], true );
691 vos_mem_free( pSmeRrmContext->channelList.ChannelList );
692#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800693 smsLog( pMac, LOGE, FL("Free memory for ChannelList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700694#endif
695 }
696
697 return eHAL_STATUS_SUCCESS;
698}
699
700/*--------------------------------------------------------------------------
701 \brief sme_RrmIssueScanReq() - This is called to send a scan request as part
702 of beacon report request .
703
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800704 \param pMac - pMac global pointer
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
706 \return eHAL_STATUS_SUCCESS - Validation is successful.
707
708 \sa
709
710 --------------------------------------------------------------------------*/
711eHalStatus sme_RrmIssueScanReq( tpAniSirGlobal pMac )
712{
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 eHalStatus status = eHAL_STATUS_SUCCESS;
714 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800715 tSirScanType scanType;
Jeff Johnson295189b2012-06-20 16:38:30 -0700716
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800717 if ((pSmeRrmContext->currentIndex) >= pSmeRrmContext->channelList.numOfChannels)
718 return status;
719
Kanchanapally, Vidyullatha5dbeaf22014-03-05 20:18:33 +0530720 if( eRRM_MSG_SOURCE_ESE_UPLOAD == pSmeRrmContext->msgSource ||
721 eRRM_MSG_SOURCE_LEGACY_ESE == pSmeRrmContext->msgSource )
722 scanType = pSmeRrmContext->measMode[pSmeRrmContext->currentIndex];
723 else
724 scanType = pSmeRrmContext->measMode[0];
725
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800726 if ((eSIR_ACTIVE_SCAN == scanType) || (eSIR_PASSIVE_SCAN == scanType))
727 {
Padma, Santhosh Kumard5421562018-01-24 19:57:40 +0530728 tCsrScanRequest scanRequest;
729 v_U32_t scanId = 0;
730 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700731#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800732 smsLog( pMac, LOGE, "Issue scan request " );
Jeff Johnson295189b2012-06-20 16:38:30 -0700733#endif
734
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800735 vos_mem_zero( &scanRequest, sizeof(scanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -0700736
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800737 /* set scanType, active or passive */
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800738 scanRequest.scanType = scanType;
Jeff Johnson295189b2012-06-20 16:38:30 -0700739
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800740 vos_mem_copy(scanRequest.bssid,
741 pSmeRrmContext->bssId, sizeof(scanRequest.bssid) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700742
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800743 if (pSmeRrmContext->ssId.length)
744 {
745 scanRequest.SSIDs.numOfSSIDs = 1;
746 scanRequest.SSIDs.SSIDList =( tCsrSSIDInfo *)vos_mem_malloc(sizeof(tCsrSSIDInfo));
747 if (NULL == scanRequest.SSIDs.SSIDList)
748 {
749 smsLog( pMac, LOGP, FL("vos_mem_malloc failed:") );
750 return eHAL_STATUS_FAILURE;
751 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700752#if defined WLAN_VOWIFI_DEBUG
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800753 smsLog( pMac, LOGE, FL("Allocated memory for pSSIDList"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700754#endif
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800755 vos_mem_zero( scanRequest.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) );
756 scanRequest.SSIDs.SSIDList->SSID.length = pSmeRrmContext->ssId.length;
757 vos_mem_copy(scanRequest.SSIDs.SSIDList->SSID.ssId, pSmeRrmContext->ssId.ssId, pSmeRrmContext->ssId.length);
758 }
759
760 /* set min and max channel time */
761 scanRequest.minChnTime = 0; //pSmeRrmContext->duration; Dont use min timeout.
Kanchanapally, Vidyullatha5dbeaf22014-03-05 20:18:33 +0530762 if( eRRM_MSG_SOURCE_ESE_UPLOAD == pSmeRrmContext->msgSource ||
763 eRRM_MSG_SOURCE_LEGACY_ESE == pSmeRrmContext->msgSource )
764 scanRequest.maxChnTime = pSmeRrmContext->duration[pSmeRrmContext->currentIndex];
765 else
766 scanRequest.maxChnTime = pSmeRrmContext->duration[0];
767
Sushant Kaushike0d2cce2014-04-10 14:36:07 +0530768 smsLog( pMac, LOG1, "Scan Type(%s (%d)) Max Dwell Time(%d)",
769 lim_ScanTypetoString(scanRequest.scanType),
770 scanRequest.scanType,
771 scanRequest.maxChnTime );
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800772
Padma, Santhosh Kumarc7c22552016-03-21 13:07:52 +0530773 RRM_scan_timer = vos_timer_get_system_time();
774
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800775#if defined WLAN_VOWIFI_DEBUG
776 smsLog( pMac, LOGE, "For Duration %d ", scanRequest.maxChnTime );
777#endif
778
779 /* set BSSType to default type */
780 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
781
782 /*Scan all the channels */
783 scanRequest.ChannelInfo.numOfChannels = 1;
784
785 scanRequest.ChannelInfo.ChannelList = &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex];
786#if defined WLAN_VOWIFI_DEBUG
787 smsLog( pMac, LOGE, "On channel %d ", pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex] );
788#endif
789
790 /* set requestType to full scan */
791 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
792
793 csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid*)pSmeRrmContext->sessionBssId, &sessionId );
794 status = sme_ScanRequest( pMac, (tANI_U8)sessionId, &scanRequest, &scanId, &sme_RrmScanRequestCallback, NULL );
795
796 if ( pSmeRrmContext->ssId.length )
797 {
798 vos_mem_free(scanRequest.SSIDs.SSIDList);
799#if defined WLAN_VOWIFI_DEBUG
800 smsLog( pMac, LOGE, FL("Free memory for SSIDList"));
801#endif
802 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800804 else if (2 == scanType) /* beacon table */
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 {
Padma, Santhosh Kumarc7c22552016-03-21 13:07:52 +0530806 /*In beacon table mode, scan results are taken directly from scan cache
807 without issuing any scan request. So, it is not proper to update
808 RRM_scan_timer with latest time and hence made it to zero to satisfy
809 pScanResult->timer >= RRM_scan_timer */
810 RRM_scan_timer = 0;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800811 if ((pSmeRrmContext->currentIndex + 1) < pSmeRrmContext->channelList.numOfChannels)
812 {
813 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], false );
814 pSmeRrmContext->currentIndex++; //Advance the current index.
815 sme_RrmIssueScanReq(pMac);
816 }
817 else
818 {
819 //Done with the measurement. Clean up all context and send a message to PE with measurement done flag set.
820 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], true );
821 vos_mem_free( pSmeRrmContext->channelList.ChannelList );
822 }
823 }
824 else
825 {
Sushant Kaushike0d2cce2014-04-10 14:36:07 +0530826 smsLog( pMac, LOGE, "Unknown beacon report request mode(%s (%d))",
827 lim_ScanTypetoString(scanType), scanType);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800828 /* Indicate measurement completion to PE */
829 /* If this is not done, pCurrentReq pointer will not be freed and
830 PE will not handle subsequent Beacon requests */
831 sme_RrmSendBeaconReportXmitInd(pMac, NULL, true, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 }
833
834 return status;
835}
836
837/*--------------------------------------------------------------------------
838 \brief sme_RrmProcessBeaconReportReqInd() - This is called to process the Beacon
839 report request from peer AP forwarded through PE .
840
841 \param pMsgBuf - a pointer to a buffer that maps to various structures base
842 on the message type.
843 The beginning of the buffer can always map to tSirSmeRsp.
844
845 \return eHAL_STATUS_SUCCESS - Validation is successful.
846
847 \sa
848
849 --------------------------------------------------------------------------*/
850void sme_RrmProcessBeaconReportReqInd(tpAniSirGlobal pMac, void *pMsgBuf)
851{
852 tpSirBeaconReportReqInd pBeaconReq = (tpSirBeaconReportReqInd) pMsgBuf;
853 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800854 tANI_U32 len = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700855
856#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800857 smsLog( pMac, LOGE, "Received Beacon report request ind Channel = %d", pBeaconReq->channelInfo.channelNum );
Jeff Johnson295189b2012-06-20 16:38:30 -0700858#endif
Abhinav Kumarfe7c94b2019-05-30 11:18:39 +0530859
860 if (pBeaconReq->channelList.numChannels > SIR_ESE_MAX_MEAS_IE_REQS) {
861 smsLog( pMac, LOGP, "Beacon report request numChannels: %u exceeds "
862 "max num channels", pBeaconReq->channelList.numChannels);
863 return;
864 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 //section 11.10.8.1 (IEEE Std 802.11k-2008)
866 //channel 0 and 255 has special meaning.
867 if( (pBeaconReq->channelInfo.channelNum == 0) ||
868 ((pBeaconReq->channelInfo.channelNum == 255) && (pBeaconReq->channelList.numChannels == 0) ) )
869 {
870 //Add all the channel in the regulatory domain.
871 wlan_cfgGetStrLen( pMac, WNI_CFG_VALID_CHANNEL_LIST, &len );
872 pSmeRrmContext->channelList.ChannelList = vos_mem_malloc( len );
873 if( pSmeRrmContext->channelList.ChannelList == NULL )
874 {
875 smsLog( pMac, LOGP, FL("vos_mem_malloc failed:") );
876 return;
877 }
878#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800879 smsLog( pMac, LOGE, FL("Allocated memory for ChannelList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700880#endif
881 csrGetCfgValidChannels( pMac, pSmeRrmContext->channelList.ChannelList, &len );
882 pSmeRrmContext->channelList.numOfChannels = (tANI_U8)len;
883#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800884 smsLog( pMac, LOGE, "channel == 0 performing on all channels");
Jeff Johnson295189b2012-06-20 16:38:30 -0700885#endif
886 }
887 else
888 {
889 len = 0;
890 pSmeRrmContext->channelList.numOfChannels = 0;
891
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800892 //If valid channel is present. We first Measure on the given channel. and
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 //if there are additional channels present in APchannelreport, measure on these also.
894 if ( pBeaconReq->channelInfo.channelNum != 255 )
895 len = 1;
896#if defined WLAN_VOWIFI_DEBUG
897 else
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800898 smsLog( pMac, LOGE, "channel == 255");
Jeff Johnson295189b2012-06-20 16:38:30 -0700899#endif
900
901 len += pBeaconReq->channelList.numChannels;
902
903 pSmeRrmContext->channelList.ChannelList = vos_mem_malloc( len );
904 if( pSmeRrmContext->channelList.ChannelList == NULL )
905 {
906 smsLog( pMac, LOGP, FL("vos_mem_malloc failed") );
907 return;
908 }
909#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800910 smsLog( pMac, LOGE, FL("Allocated memory for ChannelList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700911#endif
912
913 if ( pBeaconReq->channelInfo.channelNum != 255 )
914 {
915#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800916 smsLog( pMac, LOGE, "channel == %d ", pBeaconReq->channelInfo.channelNum );
Jeff Johnson295189b2012-06-20 16:38:30 -0700917#endif
918 if(csrRoamIsChannelValid( pMac, pBeaconReq->channelInfo.channelNum ))
919 pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->channelList.numOfChannels++] = pBeaconReq->channelInfo.channelNum;
920#if defined WLAN_VOWIFI_DEBUG
921 else
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800922 smsLog( pMac, LOGE, "is Invalid channel, Ignoring this channel" );
Jeff Johnson295189b2012-06-20 16:38:30 -0700923#endif
924 }
925
926 for ( i = 0 ; i < pBeaconReq->channelList.numChannels; i++ )
927 {
928 if(csrRoamIsChannelValid( pMac, pBeaconReq->channelList.channelNumber[i] ))
929 {
930 pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->channelList.numOfChannels] = pBeaconReq->channelList.channelNumber[i];
931 pSmeRrmContext->channelList.numOfChannels++;
932 }
933 }
934 }
935
936 //Copy session bssid
937 vos_mem_copy( pSmeRrmContext->sessionBssId, pBeaconReq->bssId, sizeof(tSirMacAddr) );
938
939 //copy measurement bssid
940 vos_mem_copy( pSmeRrmContext->bssId, pBeaconReq->macaddrBssid, sizeof(tSirMacAddr) );
941
942 //Copy ssid
943 vos_mem_copy( &pSmeRrmContext->ssId, &pBeaconReq->ssId, sizeof(tAniSSID) );
944
945 pSmeRrmContext->token = pBeaconReq->uDialogToken;
946 pSmeRrmContext->regClass = pBeaconReq->channelInfo.regulatoryClass;
Kanchanapally, Vidyullatha5dbeaf22014-03-05 20:18:33 +0530947 pSmeRrmContext->randnIntvl = VOS_MAX( pBeaconReq->randomizationInterval, pSmeRrmContext->rrmConfig.maxRandnInterval );
948 pSmeRrmContext->currentIndex = 0;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800949 pSmeRrmContext->msgSource = pBeaconReq->msgSource;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800950 vos_mem_copy((tANI_U8*)&pSmeRrmContext->measMode, (tANI_U8*)&pBeaconReq->fMeasurementtype, SIR_ESE_MAX_MEAS_IE_REQS);
951 vos_mem_copy((tANI_U8*)&pSmeRrmContext->duration, (tANI_U8*)&pBeaconReq->measurementDuration, SIR_ESE_MAX_MEAS_IE_REQS);
Jeff Johnson295189b2012-06-20 16:38:30 -0700952
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800953 sme_RrmIssueScanReq( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700954
955 return;
956}
957
958/*--------------------------------------------------------------------------
959 \brief sme_RrmNeighborReportRequest() - This is API can be used to trigger a
960 Neighbor report from the peer.
961
962 \param sessionId - session identifier on which the request should be made.
963 \param pNeighborReq - a pointer to a neighbor report request.
964
965 \return eHAL_STATUS_SUCCESS - Validation is successful.
966
967 \sa
968
969 --------------------------------------------------------------------------*/
970VOS_STATUS sme_RrmNeighborReportRequest(tpAniSirGlobal pMac, tANI_U8 sessionId,
971 tpRrmNeighborReq pNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
972{
973 eHalStatus status = eHAL_STATUS_SUCCESS;
974 tpSirNeighborReportReqInd pMsg;
975 tCsrRoamSession *pSession;
976
977#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800978 smsLog( pMac, LOGE, FL("Request to send Neighbor report request received "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700979#endif
980 if( !CSR_IS_SESSION_VALID( pMac, sessionId ) )
981 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800982 smsLog( pMac, LOGE, FL("Invalid session %d"), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 return VOS_STATUS_E_INVAL;
984 }
985 pSession = CSR_GET_SESSION( pMac, sessionId );
986
987 /* If already a report is pending, return failure */
988 if (eANI_BOOLEAN_TRUE == pMac->rrm.rrmSmeContext.neighborReqControlInfo.isNeighborRspPending)
989 {
990 smsLog( pMac, LOGE, FL("Neighbor request already pending.. Not allowed"));
991 return VOS_STATUS_E_AGAIN;
992 }
993
994 pMsg = vos_mem_malloc ( sizeof(tSirNeighborReportReqInd) );
995 if ( NULL == pMsg )
996 {
997 smsLog( pMac, LOGE, "Unable to allocate memory for Neighbor request");
998 return VOS_STATUS_E_NOMEM;
999 }
1000
1001
1002 vos_mem_zero( pMsg, sizeof(tSirNeighborReportReqInd) );
1003#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001004 smsLog( pMac, LOGE, FL(" Allocated memory for Neighbor request") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001005#endif
1006
1007 rrmLLPurgeNeighborCache(pMac, &pMac->rrm.rrmSmeContext.neighborReportCache);
1008
1009#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001010 smsLog( pMac, LOGE, FL("Purged the neighbor cache before sending Neighbor request: Status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001011#endif
1012
1013 pMsg->messageType = eWNI_SME_NEIGHBOR_REPORT_REQ_IND;
1014 pMsg->length = sizeof( tSirNeighborReportReqInd );
1015 vos_mem_copy( &pMsg->bssId, &pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
1016 pMsg->noSSID = pNeighborReq->no_ssid;
1017 vos_mem_copy( &pMsg->ucSSID, &pNeighborReq->ssid, sizeof(tSirMacSSid));
1018
1019 status = palSendMBMessage(pMac->hHdd, pMsg);
1020 if( status != eHAL_STATUS_SUCCESS )
1021 return VOS_STATUS_E_FAILURE;
1022
1023 /* Neighbor report request message sent successfully to PE. Now register the callbacks */
1024 pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallback =
1025 callbackInfo->neighborRspCallback;
1026 pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallbackContext =
1027 callbackInfo->neighborRspCallbackContext;
1028 pMac->rrm.rrmSmeContext.neighborReqControlInfo.isNeighborRspPending = eANI_BOOLEAN_TRUE;
1029
1030 /* Start neighbor response wait timer now */
1031 vos_timer_start(&pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspWaitTimer, callbackInfo->timeout);
1032
1033 return VOS_STATUS_SUCCESS;
1034}
1035
1036/*--------------------------------------------------------------------------
1037 \brief rrmCalculateNeighborAPRoamScore() - This API is called while handling
1038 individual neighbor reports from the APs neighbor AP report to
1039 calculate the cumulative roam score before storing it in neighbor
1040 cache.
1041
1042 \param pNeighborReportDesc - Neighbor BSS Descriptor node for which roam score
1043 should be calculated
1044
1045 \return void.
1046--------------------------------------------------------------------------*/
1047static void rrmCalculateNeighborAPRoamScore(tpAniSirGlobal pMac, tpRrmNeighborReportDesc pNeighborReportDesc)
1048{
1049 tpSirNeighborBssDescripton pNeighborBssDesc;
1050 tANI_U32 roamScore = 0;
1051
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -07001052 if (NULL == pNeighborReportDesc)
1053 {
1054 VOS_ASSERT(0);
1055 return;
1056 }
1057 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1058 {
1059 VOS_ASSERT(0);
1060 return;
1061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001062
1063 pNeighborBssDesc = pNeighborReportDesc->pNeighborBssDescription;
1064
1065 if (pNeighborBssDesc->bssidInfo.rrmInfo.fMobilityDomain)
1066 {
1067 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_MOBILITY_DOMAIN;
1068 if (pNeighborBssDesc->bssidInfo.rrmInfo.fSameSecurityMode)
1069 {
1070 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_SECURITY;
1071 if (pNeighborBssDesc->bssidInfo.rrmInfo.fSameAuthenticator)
1072 {
1073 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_KEY_SCOPE;
1074 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapRadioMeasurement)
1075 {
1076 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_RRM;
1077 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapSpectrumMeasurement)
1078 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_SPECTRUM_MGMT;
1079 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapQos)
1080 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_QOS;
1081 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapApsd)
1082 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_APSD;
1083 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapDelayedBlockAck)
1084 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_DELAYED_BA;
1085 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapImmediateBlockAck)
1086 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_IMMEDIATE_BA;
1087 if (pNeighborBssDesc->bssidInfo.rrmInfo.fApPreauthReachable)
1088 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_REACHABILITY;
1089 }
1090 }
1091 }
1092 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001093#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 // It has come in the report so its the best score
1095 if (csrNeighborRoamIs11rAssoc(pMac) == FALSE)
1096 {
1097 // IAPP Route so lets make use of this info
1098 // save all AP, as the list does not come all the time
1099 // Save and reuse till the next AP List comes to us.
1100 // Even save our own MAC address. Will be useful next time around.
1101 roamScore += RRM_ROAM_SCORE_NEIGHBOR_IAPP_LIST;
1102 }
1103#endif
1104 pNeighborReportDesc->roamScore = roamScore;
1105
1106 return;
1107}
1108
1109/*--------------------------------------------------------------------------
1110 \brief rrmStoreNeighborRptByRoamScore() - This API is called to store a given
1111 Neighbor BSS descriptor to the neighbor cache. This function
1112 stores the neighbor BSS descriptors in such a way that descriptors
1113 are sorted by roamScore in descending order
1114
1115 \param pNeighborReportDesc - Neighbor BSS Descriptor node to be stored in cache
1116
1117 \return void.
1118--------------------------------------------------------------------------*/
1119void rrmStoreNeighborRptByRoamScore(tpAniSirGlobal pMac, tpRrmNeighborReportDesc pNeighborReportDesc)
1120{
1121 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1122 tListElem *pEntry;
1123 tRrmNeighborReportDesc *pTempNeighborReportDesc;
1124
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -07001125 if (NULL == pNeighborReportDesc)
1126 {
1127 VOS_ASSERT(0);
1128 return;
1129 }
1130 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1131 {
1132 VOS_ASSERT(0);
1133 return;
1134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001135
1136 if (csrLLIsListEmpty(&pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK))
1137 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001138 smsLog(pMac, LOGE, FL("Neighbor report cache is empty.. Adding a entry now"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 /* Neighbor list cache is empty. Insert this entry in the tail */
1140 csrLLInsertTail(&pSmeRrmContext->neighborReportCache, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1141 return;
1142 }
1143 else
1144 {
1145 /* Should store the neighbor BSS description in the order sorted by roamScore in descending
1146 order. APs with highest roamScore should be the 1st entry in the list */
1147 pEntry = csrLLPeekHead(&pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK);
1148 while (pEntry != NULL)
1149 {
1150 pTempNeighborReportDesc = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1151 if (pTempNeighborReportDesc->roamScore < pNeighborReportDesc->roamScore)
1152 break;
1153 pEntry = csrLLNext(&pSmeRrmContext->neighborReportCache, pEntry, LL_ACCESS_LOCK);
1154 }
1155
1156 if (pEntry)
1157 /* This BSS roamscore is better than something in the list. Insert this before that one */
1158 csrLLInsertEntry(&pSmeRrmContext->neighborReportCache, pEntry, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1159 else
1160 /* All the entries in the list has a better roam Score than this one. Insert this at the last */
1161 csrLLInsertTail(&pSmeRrmContext->neighborReportCache, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1162 }
1163 return;
1164}
1165
1166/*--------------------------------------------------------------------------
1167 \brief sme_RrmProcessNeighborReport() - This is called to process the Neighbor
1168 report received from PE.
1169
1170 \param pMsgBuf - a pointer to a buffer that maps to various structures base
1171 on the message type.
1172 The beginning of the buffer can always map to tSirSmeRsp.
1173
1174 \return eHAL_STATUS_SUCCESS - Validation is successful.
1175
1176 \sa
1177
1178 --------------------------------------------------------------------------*/
1179eHalStatus sme_RrmProcessNeighborReport(tpAniSirGlobal pMac, void *pMsgBuf)
1180{
1181 eHalStatus status = eHAL_STATUS_SUCCESS;
1182 tpSirNeighborReportInd pNeighborRpt = (tpSirNeighborReportInd) pMsgBuf;
1183 tpRrmNeighborReportDesc pNeighborReportDesc;
1184 tANI_U8 i = 0;
1185 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1186
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001187#ifdef FEATURE_WLAN_ESE
1188 // Clear the cache for ESE.
1189 if (csrNeighborRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 {
1191 rrmLLPurgeNeighborCache(pMac,
1192 &pMac->rrm.rrmSmeContext.neighborReportCache);
1193 }
1194#endif
1195
1196 for (i = 0; i < pNeighborRpt->numNeighborReports; i++)
1197 {
1198 pNeighborReportDesc = vos_mem_malloc(sizeof(tRrmNeighborReportDesc));
1199 if (NULL == pNeighborReportDesc)
1200 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001201 smsLog( pMac, LOGE, "Failed to allocate memory for RRM Neighbor report desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 status = eHAL_STATUS_FAILED_ALLOC;
1203 goto end;
1204
1205 }
1206
1207 vos_mem_zero(pNeighborReportDesc, sizeof(tRrmNeighborReportDesc));
1208 pNeighborReportDesc->pNeighborBssDescription = vos_mem_malloc(sizeof(tSirNeighborBssDescription));
1209 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1210 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001211 smsLog( pMac, LOGE, "Failed to allocate memory for RRM Neighbor report BSS Description");
Jeff Johnsonfb82ea52013-04-03 15:35:49 -07001212 vos_mem_free(pNeighborReportDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 status = eHAL_STATUS_FAILED_ALLOC;
1214 goto end;
1215 }
1216 vos_mem_zero(pNeighborReportDesc->pNeighborBssDescription, sizeof(tSirNeighborBssDescription));
1217 vos_mem_copy(pNeighborReportDesc->pNeighborBssDescription, &pNeighborRpt->sNeighborBssDescription[i],
1218 sizeof(tSirNeighborBssDescription));
1219
1220#if defined WLAN_VOWIFI_DEBUG
Arif Hussain24bafea2013-11-15 15:10:03 -08001221 smsLog( pMac, LOGE, "Received neighbor report with Neighbor BSSID: "MAC_ADDRESS_STR,
1222 MAC_ADDR_ARRAY(pNeighborRpt->sNeighborBssDescription[i].bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001223#endif
1224
1225 /* Calculate the roam score based on the BSS Capability in the BSSID Information and store it in Neighbor report Desc */
1226 rrmCalculateNeighborAPRoamScore(pMac, pNeighborReportDesc);
1227
1228 /* Store the Neighbor report Desc in the cache based on the roam score */
1229 if ( pNeighborReportDesc->roamScore > 0)
1230 {
1231 rrmStoreNeighborRptByRoamScore(pMac, pNeighborReportDesc);
1232 }
1233 else
1234 {
Arif Hussain24bafea2013-11-15 15:10:03 -08001235 smsLog(pMac, LOGE, FL("Roam score of BSSID "MAC_ADDRESS_STR" is 0, Ignoring.."),
1236 MAC_ADDR_ARRAY(pNeighborRpt->sNeighborBssDescription[i].bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001237
1238 vos_mem_free(pNeighborReportDesc->pNeighborBssDescription);
1239 vos_mem_free(pNeighborReportDesc);
1240 }
1241 }
1242end:
1243
1244 if (!csrLLCount(&pMac->rrm.rrmSmeContext.neighborReportCache))
1245 vosStatus = VOS_STATUS_E_FAILURE;
1246
1247 /* Received a report from AP. Indicate SUCCESS to the caller if there are some valid reports */
1248 rrmIndicateNeighborReportResult(pMac, vosStatus);
1249
1250 return status;
1251}
1252/*--------------------------------------------------------------------------
1253 \brief sme_RrmMsgProcessor() - sme_ProcessMsg() calls this function for the
1254 messages that are handled by SME RRM module.
1255
1256 \param pMac - Pointer to the global MAC parameter structure.
1257 \param msg_type - the type of msg passed by PE as defined in wniApi.h
1258 \param pMsgBuf - a pointer to a buffer that maps to various structures base
1259 on the message type.
1260 The beginning of the buffer can always map to tSirSmeRsp.
1261
1262 \return eHAL_STATUS_SUCCESS - Validation is successful.
1263
1264 \sa
1265
1266 --------------------------------------------------------------------------*/
1267eHalStatus sme_RrmMsgProcessor( tpAniSirGlobal pMac, v_U16_t msg_type,
1268 void *pMsgBuf)
1269{
1270 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001271 FL(" Msg = %d for RRM measurement") , msg_type );
Jeff Johnson295189b2012-06-20 16:38:30 -07001272
1273 //switch on the msg type & make the state transition accordingly
1274 switch(msg_type)
1275 {
1276 case eWNI_SME_NEIGHBOR_REPORT_IND:
1277 sme_RrmProcessNeighborReport( pMac, pMsgBuf );
1278 break;
1279
1280 case eWNI_SME_BEACON_REPORT_REQ_IND:
1281 sme_RrmProcessBeaconReportReqInd( pMac, pMsgBuf );
1282 break;
1283
1284 default:
1285 //err msg
1286 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001287 FL("sme_RrmMsgProcessor:unknown msg type = %d"), msg_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07001288
1289 break;
1290 }
1291
1292 return eHAL_STATUS_SUCCESS;
1293}
1294
1295/* ---------------------------------------------------------------------------
1296
1297 \fn rrmIterMeasTimerHandle
1298
1299 \brief Timer handler to handlet the timeout condition when a specific BT
1300
1301 stop event does not come back, in which case to restore back the
1302
1303 heartbeat timer.
1304
1305 \param pMac - The handle returned by macOpen.
1306
1307 \return VOID
1308
1309 ---------------------------------------------------------------------------*/
1310
1311void rrmIterMeasTimerHandle( v_PVOID_t userData )
1312{
1313 tpAniSirGlobal pMac = (tpAniSirGlobal) userData;
1314#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001315 smsLog( pMac, LOGE, "Randomization timer expired...send on next channel ");
Jeff Johnson295189b2012-06-20 16:38:30 -07001316#endif
1317 //Issue a scan req for next channel.
1318 sme_RrmIssueScanReq( pMac );
1319}
1320
1321/* ---------------------------------------------------------------------------
1322
1323 \fn rrmNeighborRspTimeoutHandler
1324
1325 \brief Timer handler to handle the timeout condition when a neighbor request is sent
1326 and no neighbor response is received from the AP
1327
1328 \param pMac - The handle returned by macOpen.
1329
1330 \return VOID
1331
1332---------------------------------------------------------------------------*/
1333
1334void rrmNeighborRspTimeoutHandler
1335( v_PVOID_t userData )
1336{
1337 tpAniSirGlobal pMac = (tpAniSirGlobal) userData;
1338#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001339 smsLog( pMac, LOGE, "Neighbor Response timed out ");
Jeff Johnson295189b2012-06-20 16:38:30 -07001340#endif
1341 rrmIndicateNeighborReportResult(pMac, VOS_STATUS_E_FAILURE);
1342 return;
1343}
1344
1345/* ---------------------------------------------------------------------------
1346
1347 \fn rrmOpen
1348
1349 \brief
1350
1351 \param pMac - The handle returned by macOpen.
1352
1353 \return VOS_STATUS
1354
1355 VOS_STATUS_E_FAILURE success
1356
1357 VOS_STATUS_SUCCESS failure
1358
1359 ---------------------------------------------------------------------------*/
1360
1361VOS_STATUS rrmOpen (tpAniSirGlobal pMac)
1362
1363{
1364
1365 VOS_STATUS vosStatus;
1366 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1367 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1368
1369 pSmeRrmContext->rrmConfig.maxRandnInterval = 50; //ms
1370
1371 vosStatus = vos_timer_init( &pSmeRrmContext->IterMeasTimer,
1372
1373 VOS_TIMER_TYPE_SW,
1374
1375 rrmIterMeasTimerHandle,
1376
1377 (void*) pMac);
1378
1379 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
1380
1381 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to init timer");
1382
1383 return VOS_STATUS_E_FAILURE;
1384 }
1385
1386 vosStatus = vos_timer_init( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer,
1387
1388 VOS_TIMER_TYPE_SW,
1389
1390 rrmNeighborRspTimeoutHandler,
1391
1392 (void*) pMac);
1393
1394 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
1395
1396 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to init timer");
1397
1398 return VOS_STATUS_E_FAILURE;
1399 }
1400
1401 pSmeRrmContext->neighborReqControlInfo.isNeighborRspPending = eANI_BOOLEAN_FALSE;
1402
1403 halStatus = csrLLOpen(pMac->hHdd, &pSmeRrmContext->neighborReportCache);
1404 if (eHAL_STATUS_SUCCESS != halStatus)
1405 {
1406 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to open neighbor cache result");
1407 return VOS_STATUS_E_FAILURE;
1408 }
1409
1410 return VOS_STATUS_SUCCESS;
1411}
1412
1413
1414/* ---------------------------------------------------------------------------
1415
1416 \fn rrmClose
1417
1418 \brief
1419
1420 \param pMac - The handle returned by macOpen.
1421
1422 \return VOS_STATUS
1423
1424 VOS_STATUS_E_FAILURE success
1425
1426 VOS_STATUS_SUCCESS failure
1427
1428 ---------------------------------------------------------------------------*/
1429
1430VOS_STATUS rrmClose (tpAniSirGlobal pMac)
1431
1432{
1433
1434 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1435 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1436
1437 if( VOS_TIMER_STATE_RUNNING == vos_timer_getCurrentState( &pSmeRrmContext->IterMeasTimer ) )
1438 {
1439 vosStatus = vos_timer_stop( &pSmeRrmContext->IterMeasTimer );
1440 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001441 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("Timer stop fail") );
1443 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001445
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001446 vosStatus = vos_timer_destroy( &pSmeRrmContext->IterMeasTimer );
1447 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1448 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001449
1450 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("Fail to destroy timer") );
1451
1452 }
1453
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001454 if( VOS_TIMER_STATE_RUNNING ==
1455 vos_timer_getCurrentState( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer ) )
1456 {
1457 vosStatus = vos_timer_stop( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer );
1458 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1459 {
1460 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, FL("Timer stop fail") );
1461 }
1462 }
1463
1464 vosStatus = vos_timer_destroy( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer );
1465 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1466 {
1467 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, FL("Fail to destroy timer") );
1468
1469 }
1470
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 rrmLLPurgeNeighborCache(pMac, &pSmeRrmContext->neighborReportCache);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001472
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 csrLLClose(&pSmeRrmContext->neighborReportCache);
1474
1475 return vosStatus;
1476
1477}
1478
1479
1480
1481
1482/* ---------------------------------------------------------------------------
1483
1484 \fn rrmReady
1485
1486 \brief fn
1487
1488 \param pMac - The handle returned by macOpen.
1489
1490 \return VOS_STATUS
1491
1492 ---------------------------------------------------------------------------*/
1493
1494VOS_STATUS rrmReady (tpAniSirGlobal pMac)
1495
1496{
1497
1498 return VOS_STATUS_SUCCESS;
1499}
1500
1501/* ---------------------------------------------------------------------------
1502
1503 \fn rrmChangeDefaultConfigParam
1504 \brief fn
1505
1506 \param pMac - The handle returned by macOpen.
1507 \param pRrmConfig - pointer to new rrm configs.
1508
1509 \return VOS_STATUS
1510
1511 ---------------------------------------------------------------------------*/
1512VOS_STATUS rrmChangeDefaultConfigParam(tpAniSirGlobal pMac, tpRrmConfigParam pRrmConfig)
1513{
1514 vos_mem_copy( &pMac->rrm.rrmSmeContext.rrmConfig, pRrmConfig, sizeof( tRrmConfigParam ) );
1515
1516 return VOS_STATUS_SUCCESS;
1517}
1518
1519/* ---------------------------------------------------------------------------
1520
1521 \fn smeRrmGetFirstBssEntryFromNeighborCache()
1522
1523 \brief This function returns the first entry from the neighbor cache to the caller
1524
1525 \param pMac - The handle returned by macOpen.
1526
1527 \return VOID
1528
1529---------------------------------------------------------------------------*/
1530tRrmNeighborReportDesc* smeRrmGetFirstBssEntryFromNeighborCache( tpAniSirGlobal pMac)
1531{
1532 tListElem *pEntry;
1533 tRrmNeighborReportDesc *pTempBssEntry = NULL;
1534 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1535
1536
1537 pEntry = csrLLPeekHead( &pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK );
1538
1539 if(!pEntry || !csrLLCount(&pSmeRrmContext->neighborReportCache))
1540 {
1541 //list empty
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001542 smsLog(pMac, LOGW, FL("List empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 return NULL;
1544 }
1545
1546 pTempBssEntry = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1547
1548 return pTempBssEntry;
1549}
1550
1551/* ---------------------------------------------------------------------------
1552
1553 \fn smeRrmGetNextBssEntryFromNeighborCache()
1554
1555 \brief This function returns the entry next to the given entry from the
1556 neighbor cache to the caller
1557
1558 \param pMac - The handle returned by macOpen.
1559
1560 \return VOID
1561
1562---------------------------------------------------------------------------*/
1563tRrmNeighborReportDesc* smeRrmGetNextBssEntryFromNeighborCache( tpAniSirGlobal pMac,
1564 tpRrmNeighborReportDesc pBssEntry)
1565{
1566 tListElem *pEntry;
1567 tRrmNeighborReportDesc *pTempBssEntry = NULL;
1568
1569 pEntry = csrLLNext(&pMac->rrm.rrmSmeContext.neighborReportCache, &pBssEntry->List, LL_ACCESS_LOCK);
1570
1571 if(!pEntry)
1572 {
1573 //list empty
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001574 smsLog(pMac, LOGW, FL("List empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 return NULL;
1576 }
1577
1578 pTempBssEntry = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1579
1580 return pTempBssEntry;
1581}
1582
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001583#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
1584void csrEseSendAdjacentApRepMsg(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -07001585{
1586 tpSirAdjacentApRepInd pAdjRep;
1587 tANI_U16 length;
1588 tANI_U32 roamTS2;
1589
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001590 smsLog( pMac, LOG1, "Adjacent AP Report Msg to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07001591
1592 length = sizeof(tSirAdjacentApRepInd );
1593 pAdjRep = vos_mem_malloc ( length );
1594
1595 if ( NULL == pAdjRep )
1596 {
1597 smsLog( pMac, LOGP, "Unable to allocate memory for Adjacent AP report");
1598 return;
1599 }
1600
1601 vos_mem_zero( pAdjRep, length );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001602 pAdjRep->messageType = eWNI_SME_ESE_ADJACENT_AP_REPORT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 pAdjRep->length = length;
1604 pAdjRep->channelNum = pSession->prevOpChannel;
1605 vos_mem_copy( pAdjRep->bssid, &pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
1606 vos_mem_copy( pAdjRep->prevApMacAddr, &pSession->prevApBssid, sizeof(tSirMacAddr) );
1607 vos_mem_copy( &pAdjRep->prevApSSID, &pSession->prevApSSID, sizeof(tSirMacSSid) );
1608 roamTS2 = vos_timer_get_system_time();
1609 pAdjRep->tsmRoamdelay = roamTS2 - pSession->roamTS1;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001610 pAdjRep->roamReason =SIR_ESE_ASSOC_REASON_UNSPECIFIED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 pAdjRep->clientDissSecs =(pAdjRep->tsmRoamdelay/1000);
1612
1613 palSendMBMessage(pMac->hHdd, pAdjRep);
1614
1615 return;
1616}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001617#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001618#endif