blob: 0cb94aff40074f1ff10d67f1d60ec353c350996e [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;
louisliu6cf41b32020-11-20 15:13:15 +0800730 tANI_U32 sessionId = 0;
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
louisliu6cf41b32020-11-20 15:13:15 +0800793 status = csrRoamGetSessionIdFromBSSID(pMac,
794 (tCsrBssid*)pSmeRrmContext->sessionBssId, &sessionId );
795 if (!HAL_STATUS_SUCCESS(status)) {
796 smsLog( pMac, LOGE, FL("sessionId not found for Offload scan req"));
797 return status;
798 }
799
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800800 status = sme_ScanRequest( pMac, (tANI_U8)sessionId, &scanRequest, &scanId, &sme_RrmScanRequestCallback, NULL );
801
802 if ( pSmeRrmContext->ssId.length )
803 {
804 vos_mem_free(scanRequest.SSIDs.SSIDList);
805#if defined WLAN_VOWIFI_DEBUG
806 smsLog( pMac, LOGE, FL("Free memory for SSIDList"));
807#endif
808 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800810 else if (2 == scanType) /* beacon table */
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 {
Padma, Santhosh Kumarc7c22552016-03-21 13:07:52 +0530812 /*In beacon table mode, scan results are taken directly from scan cache
813 without issuing any scan request. So, it is not proper to update
814 RRM_scan_timer with latest time and hence made it to zero to satisfy
815 pScanResult->timer >= RRM_scan_timer */
816 RRM_scan_timer = 0;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800817 if ((pSmeRrmContext->currentIndex + 1) < pSmeRrmContext->channelList.numOfChannels)
818 {
819 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], false );
820 pSmeRrmContext->currentIndex++; //Advance the current index.
821 sme_RrmIssueScanReq(pMac);
822 }
823 else
824 {
825 //Done with the measurement. Clean up all context and send a message to PE with measurement done flag set.
826 sme_RrmSendScanResult( pMac, 1, &pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->currentIndex], true );
827 vos_mem_free( pSmeRrmContext->channelList.ChannelList );
828 }
829 }
830 else
831 {
Sushant Kaushike0d2cce2014-04-10 14:36:07 +0530832 smsLog( pMac, LOGE, "Unknown beacon report request mode(%s (%d))",
833 lim_ScanTypetoString(scanType), scanType);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800834 /* Indicate measurement completion to PE */
835 /* If this is not done, pCurrentReq pointer will not be freed and
836 PE will not handle subsequent Beacon requests */
837 sme_RrmSendBeaconReportXmitInd(pMac, NULL, true, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 }
839
840 return status;
841}
842
843/*--------------------------------------------------------------------------
844 \brief sme_RrmProcessBeaconReportReqInd() - This is called to process the Beacon
845 report request from peer AP forwarded through PE .
846
847 \param pMsgBuf - a pointer to a buffer that maps to various structures base
848 on the message type.
849 The beginning of the buffer can always map to tSirSmeRsp.
850
851 \return eHAL_STATUS_SUCCESS - Validation is successful.
852
853 \sa
854
855 --------------------------------------------------------------------------*/
856void sme_RrmProcessBeaconReportReqInd(tpAniSirGlobal pMac, void *pMsgBuf)
857{
858 tpSirBeaconReportReqInd pBeaconReq = (tpSirBeaconReportReqInd) pMsgBuf;
859 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800860 tANI_U32 len = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700861
862#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800863 smsLog( pMac, LOGE, "Received Beacon report request ind Channel = %d", pBeaconReq->channelInfo.channelNum );
Jeff Johnson295189b2012-06-20 16:38:30 -0700864#endif
Abhinav Kumarfe7c94b2019-05-30 11:18:39 +0530865
866 if (pBeaconReq->channelList.numChannels > SIR_ESE_MAX_MEAS_IE_REQS) {
867 smsLog( pMac, LOGP, "Beacon report request numChannels: %u exceeds "
868 "max num channels", pBeaconReq->channelList.numChannels);
869 return;
870 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 //section 11.10.8.1 (IEEE Std 802.11k-2008)
872 //channel 0 and 255 has special meaning.
873 if( (pBeaconReq->channelInfo.channelNum == 0) ||
874 ((pBeaconReq->channelInfo.channelNum == 255) && (pBeaconReq->channelList.numChannels == 0) ) )
875 {
876 //Add all the channel in the regulatory domain.
877 wlan_cfgGetStrLen( pMac, WNI_CFG_VALID_CHANNEL_LIST, &len );
878 pSmeRrmContext->channelList.ChannelList = vos_mem_malloc( len );
879 if( pSmeRrmContext->channelList.ChannelList == NULL )
880 {
881 smsLog( pMac, LOGP, FL("vos_mem_malloc failed:") );
882 return;
883 }
884#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800885 smsLog( pMac, LOGE, FL("Allocated memory for ChannelList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700886#endif
887 csrGetCfgValidChannels( pMac, pSmeRrmContext->channelList.ChannelList, &len );
888 pSmeRrmContext->channelList.numOfChannels = (tANI_U8)len;
889#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800890 smsLog( pMac, LOGE, "channel == 0 performing on all channels");
Jeff Johnson295189b2012-06-20 16:38:30 -0700891#endif
892 }
893 else
894 {
895 len = 0;
896 pSmeRrmContext->channelList.numOfChannels = 0;
897
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800898 //If valid channel is present. We first Measure on the given channel. and
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 //if there are additional channels present in APchannelreport, measure on these also.
900 if ( pBeaconReq->channelInfo.channelNum != 255 )
901 len = 1;
902#if defined WLAN_VOWIFI_DEBUG
903 else
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800904 smsLog( pMac, LOGE, "channel == 255");
Jeff Johnson295189b2012-06-20 16:38:30 -0700905#endif
906
907 len += pBeaconReq->channelList.numChannels;
908
909 pSmeRrmContext->channelList.ChannelList = vos_mem_malloc( len );
910 if( pSmeRrmContext->channelList.ChannelList == NULL )
911 {
912 smsLog( pMac, LOGP, FL("vos_mem_malloc failed") );
913 return;
914 }
915#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800916 smsLog( pMac, LOGE, FL("Allocated memory for ChannelList") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700917#endif
918
919 if ( pBeaconReq->channelInfo.channelNum != 255 )
920 {
921#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800922 smsLog( pMac, LOGE, "channel == %d ", pBeaconReq->channelInfo.channelNum );
Jeff Johnson295189b2012-06-20 16:38:30 -0700923#endif
924 if(csrRoamIsChannelValid( pMac, pBeaconReq->channelInfo.channelNum ))
925 pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->channelList.numOfChannels++] = pBeaconReq->channelInfo.channelNum;
926#if defined WLAN_VOWIFI_DEBUG
927 else
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800928 smsLog( pMac, LOGE, "is Invalid channel, Ignoring this channel" );
Jeff Johnson295189b2012-06-20 16:38:30 -0700929#endif
930 }
931
932 for ( i = 0 ; i < pBeaconReq->channelList.numChannels; i++ )
933 {
934 if(csrRoamIsChannelValid( pMac, pBeaconReq->channelList.channelNumber[i] ))
935 {
936 pSmeRrmContext->channelList.ChannelList[pSmeRrmContext->channelList.numOfChannels] = pBeaconReq->channelList.channelNumber[i];
937 pSmeRrmContext->channelList.numOfChannels++;
938 }
939 }
940 }
941
942 //Copy session bssid
943 vos_mem_copy( pSmeRrmContext->sessionBssId, pBeaconReq->bssId, sizeof(tSirMacAddr) );
944
945 //copy measurement bssid
946 vos_mem_copy( pSmeRrmContext->bssId, pBeaconReq->macaddrBssid, sizeof(tSirMacAddr) );
947
948 //Copy ssid
949 vos_mem_copy( &pSmeRrmContext->ssId, &pBeaconReq->ssId, sizeof(tAniSSID) );
950
951 pSmeRrmContext->token = pBeaconReq->uDialogToken;
952 pSmeRrmContext->regClass = pBeaconReq->channelInfo.regulatoryClass;
Kanchanapally, Vidyullatha5dbeaf22014-03-05 20:18:33 +0530953 pSmeRrmContext->randnIntvl = VOS_MAX( pBeaconReq->randomizationInterval, pSmeRrmContext->rrmConfig.maxRandnInterval );
954 pSmeRrmContext->currentIndex = 0;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800955 pSmeRrmContext->msgSource = pBeaconReq->msgSource;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800956 vos_mem_copy((tANI_U8*)&pSmeRrmContext->measMode, (tANI_U8*)&pBeaconReq->fMeasurementtype, SIR_ESE_MAX_MEAS_IE_REQS);
957 vos_mem_copy((tANI_U8*)&pSmeRrmContext->duration, (tANI_U8*)&pBeaconReq->measurementDuration, SIR_ESE_MAX_MEAS_IE_REQS);
Jeff Johnson295189b2012-06-20 16:38:30 -0700958
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800959 sme_RrmIssueScanReq( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700960
961 return;
962}
963
964/*--------------------------------------------------------------------------
965 \brief sme_RrmNeighborReportRequest() - This is API can be used to trigger a
966 Neighbor report from the peer.
967
968 \param sessionId - session identifier on which the request should be made.
969 \param pNeighborReq - a pointer to a neighbor report request.
970
971 \return eHAL_STATUS_SUCCESS - Validation is successful.
972
973 \sa
974
975 --------------------------------------------------------------------------*/
976VOS_STATUS sme_RrmNeighborReportRequest(tpAniSirGlobal pMac, tANI_U8 sessionId,
977 tpRrmNeighborReq pNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
978{
979 eHalStatus status = eHAL_STATUS_SUCCESS;
980 tpSirNeighborReportReqInd pMsg;
981 tCsrRoamSession *pSession;
982
983#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800984 smsLog( pMac, LOGE, FL("Request to send Neighbor report request received "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700985#endif
986 if( !CSR_IS_SESSION_VALID( pMac, sessionId ) )
987 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800988 smsLog( pMac, LOGE, FL("Invalid session %d"), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 return VOS_STATUS_E_INVAL;
990 }
991 pSession = CSR_GET_SESSION( pMac, sessionId );
992
993 /* If already a report is pending, return failure */
994 if (eANI_BOOLEAN_TRUE == pMac->rrm.rrmSmeContext.neighborReqControlInfo.isNeighborRspPending)
995 {
996 smsLog( pMac, LOGE, FL("Neighbor request already pending.. Not allowed"));
997 return VOS_STATUS_E_AGAIN;
998 }
999
1000 pMsg = vos_mem_malloc ( sizeof(tSirNeighborReportReqInd) );
1001 if ( NULL == pMsg )
1002 {
1003 smsLog( pMac, LOGE, "Unable to allocate memory for Neighbor request");
1004 return VOS_STATUS_E_NOMEM;
1005 }
1006
1007
1008 vos_mem_zero( pMsg, sizeof(tSirNeighborReportReqInd) );
1009#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001010 smsLog( pMac, LOGE, FL(" Allocated memory for Neighbor request") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001011#endif
1012
1013 rrmLLPurgeNeighborCache(pMac, &pMac->rrm.rrmSmeContext.neighborReportCache);
1014
1015#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001016 smsLog( pMac, LOGE, FL("Purged the neighbor cache before sending Neighbor request: Status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001017#endif
1018
1019 pMsg->messageType = eWNI_SME_NEIGHBOR_REPORT_REQ_IND;
1020 pMsg->length = sizeof( tSirNeighborReportReqInd );
1021 vos_mem_copy( &pMsg->bssId, &pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
1022 pMsg->noSSID = pNeighborReq->no_ssid;
1023 vos_mem_copy( &pMsg->ucSSID, &pNeighborReq->ssid, sizeof(tSirMacSSid));
1024
1025 status = palSendMBMessage(pMac->hHdd, pMsg);
1026 if( status != eHAL_STATUS_SUCCESS )
1027 return VOS_STATUS_E_FAILURE;
1028
1029 /* Neighbor report request message sent successfully to PE. Now register the callbacks */
1030 pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallback =
1031 callbackInfo->neighborRspCallback;
1032 pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspCallbackInfo.neighborRspCallbackContext =
1033 callbackInfo->neighborRspCallbackContext;
1034 pMac->rrm.rrmSmeContext.neighborReqControlInfo.isNeighborRspPending = eANI_BOOLEAN_TRUE;
1035
1036 /* Start neighbor response wait timer now */
1037 vos_timer_start(&pMac->rrm.rrmSmeContext.neighborReqControlInfo.neighborRspWaitTimer, callbackInfo->timeout);
1038
1039 return VOS_STATUS_SUCCESS;
1040}
1041
1042/*--------------------------------------------------------------------------
1043 \brief rrmCalculateNeighborAPRoamScore() - This API is called while handling
1044 individual neighbor reports from the APs neighbor AP report to
1045 calculate the cumulative roam score before storing it in neighbor
1046 cache.
1047
1048 \param pNeighborReportDesc - Neighbor BSS Descriptor node for which roam score
1049 should be calculated
1050
1051 \return void.
1052--------------------------------------------------------------------------*/
1053static void rrmCalculateNeighborAPRoamScore(tpAniSirGlobal pMac, tpRrmNeighborReportDesc pNeighborReportDesc)
1054{
1055 tpSirNeighborBssDescripton pNeighborBssDesc;
1056 tANI_U32 roamScore = 0;
1057
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -07001058 if (NULL == pNeighborReportDesc)
1059 {
1060 VOS_ASSERT(0);
1061 return;
1062 }
1063 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1064 {
1065 VOS_ASSERT(0);
1066 return;
1067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001068
1069 pNeighborBssDesc = pNeighborReportDesc->pNeighborBssDescription;
1070
1071 if (pNeighborBssDesc->bssidInfo.rrmInfo.fMobilityDomain)
1072 {
1073 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_MOBILITY_DOMAIN;
1074 if (pNeighborBssDesc->bssidInfo.rrmInfo.fSameSecurityMode)
1075 {
1076 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_SECURITY;
1077 if (pNeighborBssDesc->bssidInfo.rrmInfo.fSameAuthenticator)
1078 {
1079 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_KEY_SCOPE;
1080 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapRadioMeasurement)
1081 {
1082 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_RRM;
1083 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapSpectrumMeasurement)
1084 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_SPECTRUM_MGMT;
1085 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapQos)
1086 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_QOS;
1087 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapApsd)
1088 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_APSD;
1089 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapDelayedBlockAck)
1090 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_DELAYED_BA;
1091 if (pNeighborBssDesc->bssidInfo.rrmInfo.fCapImmediateBlockAck)
1092 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_CAPABILITY_IMMEDIATE_BA;
1093 if (pNeighborBssDesc->bssidInfo.rrmInfo.fApPreauthReachable)
1094 roamScore += RRM_ROAM_SCORE_NEIGHBOR_REPORT_REACHABILITY;
1095 }
1096 }
1097 }
1098 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001099#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 // It has come in the report so its the best score
1101 if (csrNeighborRoamIs11rAssoc(pMac) == FALSE)
1102 {
1103 // IAPP Route so lets make use of this info
1104 // save all AP, as the list does not come all the time
1105 // Save and reuse till the next AP List comes to us.
1106 // Even save our own MAC address. Will be useful next time around.
1107 roamScore += RRM_ROAM_SCORE_NEIGHBOR_IAPP_LIST;
1108 }
1109#endif
1110 pNeighborReportDesc->roamScore = roamScore;
1111
1112 return;
1113}
1114
1115/*--------------------------------------------------------------------------
1116 \brief rrmStoreNeighborRptByRoamScore() - This API is called to store a given
1117 Neighbor BSS descriptor to the neighbor cache. This function
1118 stores the neighbor BSS descriptors in such a way that descriptors
1119 are sorted by roamScore in descending order
1120
1121 \param pNeighborReportDesc - Neighbor BSS Descriptor node to be stored in cache
1122
1123 \return void.
1124--------------------------------------------------------------------------*/
1125void rrmStoreNeighborRptByRoamScore(tpAniSirGlobal pMac, tpRrmNeighborReportDesc pNeighborReportDesc)
1126{
1127 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1128 tListElem *pEntry;
1129 tRrmNeighborReportDesc *pTempNeighborReportDesc;
1130
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -07001131 if (NULL == pNeighborReportDesc)
1132 {
1133 VOS_ASSERT(0);
1134 return;
1135 }
1136 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1137 {
1138 VOS_ASSERT(0);
1139 return;
1140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001141
1142 if (csrLLIsListEmpty(&pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK))
1143 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001144 smsLog(pMac, LOGE, FL("Neighbor report cache is empty.. Adding a entry now"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 /* Neighbor list cache is empty. Insert this entry in the tail */
1146 csrLLInsertTail(&pSmeRrmContext->neighborReportCache, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1147 return;
1148 }
1149 else
1150 {
1151 /* Should store the neighbor BSS description in the order sorted by roamScore in descending
1152 order. APs with highest roamScore should be the 1st entry in the list */
1153 pEntry = csrLLPeekHead(&pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK);
1154 while (pEntry != NULL)
1155 {
1156 pTempNeighborReportDesc = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1157 if (pTempNeighborReportDesc->roamScore < pNeighborReportDesc->roamScore)
1158 break;
1159 pEntry = csrLLNext(&pSmeRrmContext->neighborReportCache, pEntry, LL_ACCESS_LOCK);
1160 }
1161
1162 if (pEntry)
1163 /* This BSS roamscore is better than something in the list. Insert this before that one */
1164 csrLLInsertEntry(&pSmeRrmContext->neighborReportCache, pEntry, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1165 else
1166 /* All the entries in the list has a better roam Score than this one. Insert this at the last */
1167 csrLLInsertTail(&pSmeRrmContext->neighborReportCache, &pNeighborReportDesc->List, LL_ACCESS_LOCK);
1168 }
1169 return;
1170}
1171
1172/*--------------------------------------------------------------------------
1173 \brief sme_RrmProcessNeighborReport() - This is called to process the Neighbor
1174 report received from PE.
1175
1176 \param pMsgBuf - a pointer to a buffer that maps to various structures base
1177 on the message type.
1178 The beginning of the buffer can always map to tSirSmeRsp.
1179
1180 \return eHAL_STATUS_SUCCESS - Validation is successful.
1181
1182 \sa
1183
1184 --------------------------------------------------------------------------*/
1185eHalStatus sme_RrmProcessNeighborReport(tpAniSirGlobal pMac, void *pMsgBuf)
1186{
1187 eHalStatus status = eHAL_STATUS_SUCCESS;
1188 tpSirNeighborReportInd pNeighborRpt = (tpSirNeighborReportInd) pMsgBuf;
1189 tpRrmNeighborReportDesc pNeighborReportDesc;
1190 tANI_U8 i = 0;
1191 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1192
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001193#ifdef FEATURE_WLAN_ESE
1194 // Clear the cache for ESE.
1195 if (csrNeighborRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 {
1197 rrmLLPurgeNeighborCache(pMac,
1198 &pMac->rrm.rrmSmeContext.neighborReportCache);
1199 }
1200#endif
1201
1202 for (i = 0; i < pNeighborRpt->numNeighborReports; i++)
1203 {
1204 pNeighborReportDesc = vos_mem_malloc(sizeof(tRrmNeighborReportDesc));
1205 if (NULL == pNeighborReportDesc)
1206 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001207 smsLog( pMac, LOGE, "Failed to allocate memory for RRM Neighbor report desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 status = eHAL_STATUS_FAILED_ALLOC;
1209 goto end;
1210
1211 }
1212
1213 vos_mem_zero(pNeighborReportDesc, sizeof(tRrmNeighborReportDesc));
1214 pNeighborReportDesc->pNeighborBssDescription = vos_mem_malloc(sizeof(tSirNeighborBssDescription));
1215 if (NULL == pNeighborReportDesc->pNeighborBssDescription)
1216 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001217 smsLog( pMac, LOGE, "Failed to allocate memory for RRM Neighbor report BSS Description");
Jeff Johnsonfb82ea52013-04-03 15:35:49 -07001218 vos_mem_free(pNeighborReportDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 status = eHAL_STATUS_FAILED_ALLOC;
1220 goto end;
1221 }
1222 vos_mem_zero(pNeighborReportDesc->pNeighborBssDescription, sizeof(tSirNeighborBssDescription));
1223 vos_mem_copy(pNeighborReportDesc->pNeighborBssDescription, &pNeighborRpt->sNeighborBssDescription[i],
1224 sizeof(tSirNeighborBssDescription));
1225
1226#if defined WLAN_VOWIFI_DEBUG
Arif Hussain24bafea2013-11-15 15:10:03 -08001227 smsLog( pMac, LOGE, "Received neighbor report with Neighbor BSSID: "MAC_ADDRESS_STR,
1228 MAC_ADDR_ARRAY(pNeighborRpt->sNeighborBssDescription[i].bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001229#endif
1230
1231 /* Calculate the roam score based on the BSS Capability in the BSSID Information and store it in Neighbor report Desc */
1232 rrmCalculateNeighborAPRoamScore(pMac, pNeighborReportDesc);
1233
1234 /* Store the Neighbor report Desc in the cache based on the roam score */
1235 if ( pNeighborReportDesc->roamScore > 0)
1236 {
1237 rrmStoreNeighborRptByRoamScore(pMac, pNeighborReportDesc);
1238 }
1239 else
1240 {
Arif Hussain24bafea2013-11-15 15:10:03 -08001241 smsLog(pMac, LOGE, FL("Roam score of BSSID "MAC_ADDRESS_STR" is 0, Ignoring.."),
1242 MAC_ADDR_ARRAY(pNeighborRpt->sNeighborBssDescription[i].bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001243
1244 vos_mem_free(pNeighborReportDesc->pNeighborBssDescription);
1245 vos_mem_free(pNeighborReportDesc);
1246 }
1247 }
1248end:
1249
1250 if (!csrLLCount(&pMac->rrm.rrmSmeContext.neighborReportCache))
1251 vosStatus = VOS_STATUS_E_FAILURE;
1252
1253 /* Received a report from AP. Indicate SUCCESS to the caller if there are some valid reports */
1254 rrmIndicateNeighborReportResult(pMac, vosStatus);
1255
1256 return status;
1257}
1258/*--------------------------------------------------------------------------
1259 \brief sme_RrmMsgProcessor() - sme_ProcessMsg() calls this function for the
1260 messages that are handled by SME RRM module.
1261
1262 \param pMac - Pointer to the global MAC parameter structure.
1263 \param msg_type - the type of msg passed by PE as defined in wniApi.h
1264 \param pMsgBuf - a pointer to a buffer that maps to various structures base
1265 on the message type.
1266 The beginning of the buffer can always map to tSirSmeRsp.
1267
1268 \return eHAL_STATUS_SUCCESS - Validation is successful.
1269
1270 \sa
1271
1272 --------------------------------------------------------------------------*/
1273eHalStatus sme_RrmMsgProcessor( tpAniSirGlobal pMac, v_U16_t msg_type,
1274 void *pMsgBuf)
1275{
1276 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001277 FL(" Msg = %d for RRM measurement") , msg_type );
Jeff Johnson295189b2012-06-20 16:38:30 -07001278
1279 //switch on the msg type & make the state transition accordingly
1280 switch(msg_type)
1281 {
1282 case eWNI_SME_NEIGHBOR_REPORT_IND:
1283 sme_RrmProcessNeighborReport( pMac, pMsgBuf );
1284 break;
1285
1286 case eWNI_SME_BEACON_REPORT_REQ_IND:
1287 sme_RrmProcessBeaconReportReqInd( pMac, pMsgBuf );
1288 break;
1289
1290 default:
1291 //err msg
1292 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001293 FL("sme_RrmMsgProcessor:unknown msg type = %d"), msg_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07001294
1295 break;
1296 }
1297
1298 return eHAL_STATUS_SUCCESS;
1299}
1300
1301/* ---------------------------------------------------------------------------
1302
1303 \fn rrmIterMeasTimerHandle
1304
1305 \brief Timer handler to handlet the timeout condition when a specific BT
1306
1307 stop event does not come back, in which case to restore back the
1308
1309 heartbeat timer.
1310
1311 \param pMac - The handle returned by macOpen.
1312
1313 \return VOID
1314
1315 ---------------------------------------------------------------------------*/
1316
1317void rrmIterMeasTimerHandle( v_PVOID_t userData )
1318{
1319 tpAniSirGlobal pMac = (tpAniSirGlobal) userData;
1320#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001321 smsLog( pMac, LOGE, "Randomization timer expired...send on next channel ");
Jeff Johnson295189b2012-06-20 16:38:30 -07001322#endif
1323 //Issue a scan req for next channel.
1324 sme_RrmIssueScanReq( pMac );
1325}
1326
1327/* ---------------------------------------------------------------------------
1328
1329 \fn rrmNeighborRspTimeoutHandler
1330
1331 \brief Timer handler to handle the timeout condition when a neighbor request is sent
1332 and no neighbor response is received from the AP
1333
1334 \param pMac - The handle returned by macOpen.
1335
1336 \return VOID
1337
1338---------------------------------------------------------------------------*/
1339
1340void rrmNeighborRspTimeoutHandler
1341( v_PVOID_t userData )
1342{
1343 tpAniSirGlobal pMac = (tpAniSirGlobal) userData;
1344#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001345 smsLog( pMac, LOGE, "Neighbor Response timed out ");
Jeff Johnson295189b2012-06-20 16:38:30 -07001346#endif
1347 rrmIndicateNeighborReportResult(pMac, VOS_STATUS_E_FAILURE);
1348 return;
1349}
1350
1351/* ---------------------------------------------------------------------------
1352
1353 \fn rrmOpen
1354
1355 \brief
1356
1357 \param pMac - The handle returned by macOpen.
1358
1359 \return VOS_STATUS
1360
1361 VOS_STATUS_E_FAILURE success
1362
1363 VOS_STATUS_SUCCESS failure
1364
1365 ---------------------------------------------------------------------------*/
1366
1367VOS_STATUS rrmOpen (tpAniSirGlobal pMac)
1368
1369{
1370
1371 VOS_STATUS vosStatus;
1372 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1373 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1374
1375 pSmeRrmContext->rrmConfig.maxRandnInterval = 50; //ms
1376
1377 vosStatus = vos_timer_init( &pSmeRrmContext->IterMeasTimer,
1378
1379 VOS_TIMER_TYPE_SW,
1380
1381 rrmIterMeasTimerHandle,
1382
1383 (void*) pMac);
1384
1385 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
1386
1387 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to init timer");
1388
1389 return VOS_STATUS_E_FAILURE;
1390 }
1391
1392 vosStatus = vos_timer_init( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer,
1393
1394 VOS_TIMER_TYPE_SW,
1395
1396 rrmNeighborRspTimeoutHandler,
1397
1398 (void*) pMac);
1399
1400 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
1401
1402 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to init timer");
1403
1404 return VOS_STATUS_E_FAILURE;
1405 }
1406
1407 pSmeRrmContext->neighborReqControlInfo.isNeighborRspPending = eANI_BOOLEAN_FALSE;
1408
1409 halStatus = csrLLOpen(pMac->hHdd, &pSmeRrmContext->neighborReportCache);
1410 if (eHAL_STATUS_SUCCESS != halStatus)
1411 {
1412 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "rrmOpen: Fail to open neighbor cache result");
1413 return VOS_STATUS_E_FAILURE;
1414 }
1415
1416 return VOS_STATUS_SUCCESS;
1417}
1418
1419
1420/* ---------------------------------------------------------------------------
1421
1422 \fn rrmClose
1423
1424 \brief
1425
1426 \param pMac - The handle returned by macOpen.
1427
1428 \return VOS_STATUS
1429
1430 VOS_STATUS_E_FAILURE success
1431
1432 VOS_STATUS_SUCCESS failure
1433
1434 ---------------------------------------------------------------------------*/
1435
1436VOS_STATUS rrmClose (tpAniSirGlobal pMac)
1437
1438{
1439
1440 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1441 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1442
1443 if( VOS_TIMER_STATE_RUNNING == vos_timer_getCurrentState( &pSmeRrmContext->IterMeasTimer ) )
1444 {
1445 vosStatus = vos_timer_stop( &pSmeRrmContext->IterMeasTimer );
1446 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001447 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("Timer stop fail") );
1449 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001451
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001452 vosStatus = vos_timer_destroy( &pSmeRrmContext->IterMeasTimer );
1453 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1454 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001455
1456 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("Fail to destroy timer") );
1457
1458 }
1459
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001460 if( VOS_TIMER_STATE_RUNNING ==
1461 vos_timer_getCurrentState( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer ) )
1462 {
1463 vosStatus = vos_timer_stop( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer );
1464 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1465 {
1466 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, FL("Timer stop fail") );
1467 }
1468 }
1469
1470 vosStatus = vos_timer_destroy( &pSmeRrmContext->neighborReqControlInfo.neighborRspWaitTimer );
1471 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1472 {
1473 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, FL("Fail to destroy timer") );
1474
1475 }
1476
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 rrmLLPurgeNeighborCache(pMac, &pSmeRrmContext->neighborReportCache);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001478
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 csrLLClose(&pSmeRrmContext->neighborReportCache);
1480
1481 return vosStatus;
1482
1483}
1484
1485
1486
1487
1488/* ---------------------------------------------------------------------------
1489
1490 \fn rrmReady
1491
1492 \brief fn
1493
1494 \param pMac - The handle returned by macOpen.
1495
1496 \return VOS_STATUS
1497
1498 ---------------------------------------------------------------------------*/
1499
1500VOS_STATUS rrmReady (tpAniSirGlobal pMac)
1501
1502{
1503
1504 return VOS_STATUS_SUCCESS;
1505}
1506
1507/* ---------------------------------------------------------------------------
1508
1509 \fn rrmChangeDefaultConfigParam
1510 \brief fn
1511
1512 \param pMac - The handle returned by macOpen.
1513 \param pRrmConfig - pointer to new rrm configs.
1514
1515 \return VOS_STATUS
1516
1517 ---------------------------------------------------------------------------*/
1518VOS_STATUS rrmChangeDefaultConfigParam(tpAniSirGlobal pMac, tpRrmConfigParam pRrmConfig)
1519{
1520 vos_mem_copy( &pMac->rrm.rrmSmeContext.rrmConfig, pRrmConfig, sizeof( tRrmConfigParam ) );
1521
1522 return VOS_STATUS_SUCCESS;
1523}
1524
1525/* ---------------------------------------------------------------------------
1526
1527 \fn smeRrmGetFirstBssEntryFromNeighborCache()
1528
1529 \brief This function returns the first entry from the neighbor cache to the caller
1530
1531 \param pMac - The handle returned by macOpen.
1532
1533 \return VOID
1534
1535---------------------------------------------------------------------------*/
1536tRrmNeighborReportDesc* smeRrmGetFirstBssEntryFromNeighborCache( tpAniSirGlobal pMac)
1537{
1538 tListElem *pEntry;
1539 tRrmNeighborReportDesc *pTempBssEntry = NULL;
1540 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1541
1542
1543 pEntry = csrLLPeekHead( &pSmeRrmContext->neighborReportCache, LL_ACCESS_LOCK );
1544
1545 if(!pEntry || !csrLLCount(&pSmeRrmContext->neighborReportCache))
1546 {
1547 //list empty
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001548 smsLog(pMac, LOGW, FL("List empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 return NULL;
1550 }
1551
1552 pTempBssEntry = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1553
1554 return pTempBssEntry;
1555}
1556
1557/* ---------------------------------------------------------------------------
1558
1559 \fn smeRrmGetNextBssEntryFromNeighborCache()
1560
1561 \brief This function returns the entry next to the given entry from the
1562 neighbor cache to the caller
1563
1564 \param pMac - The handle returned by macOpen.
1565
1566 \return VOID
1567
1568---------------------------------------------------------------------------*/
1569tRrmNeighborReportDesc* smeRrmGetNextBssEntryFromNeighborCache( tpAniSirGlobal pMac,
1570 tpRrmNeighborReportDesc pBssEntry)
1571{
1572 tListElem *pEntry;
1573 tRrmNeighborReportDesc *pTempBssEntry = NULL;
1574
1575 pEntry = csrLLNext(&pMac->rrm.rrmSmeContext.neighborReportCache, &pBssEntry->List, LL_ACCESS_LOCK);
1576
1577 if(!pEntry)
1578 {
1579 //list empty
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001580 smsLog(pMac, LOGW, FL("List empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 return NULL;
1582 }
1583
1584 pTempBssEntry = GET_BASE_ADDR( pEntry, tRrmNeighborReportDesc, List );
1585
1586 return pTempBssEntry;
1587}
1588
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001589#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
1590void csrEseSendAdjacentApRepMsg(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -07001591{
1592 tpSirAdjacentApRepInd pAdjRep;
1593 tANI_U16 length;
1594 tANI_U32 roamTS2;
1595
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001596 smsLog( pMac, LOG1, "Adjacent AP Report Msg to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07001597
1598 length = sizeof(tSirAdjacentApRepInd );
1599 pAdjRep = vos_mem_malloc ( length );
1600
1601 if ( NULL == pAdjRep )
1602 {
1603 smsLog( pMac, LOGP, "Unable to allocate memory for Adjacent AP report");
1604 return;
1605 }
1606
1607 vos_mem_zero( pAdjRep, length );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001608 pAdjRep->messageType = eWNI_SME_ESE_ADJACENT_AP_REPORT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 pAdjRep->length = length;
1610 pAdjRep->channelNum = pSession->prevOpChannel;
1611 vos_mem_copy( pAdjRep->bssid, &pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
1612 vos_mem_copy( pAdjRep->prevApMacAddr, &pSession->prevApBssid, sizeof(tSirMacAddr) );
1613 vos_mem_copy( &pAdjRep->prevApSSID, &pSession->prevApSSID, sizeof(tSirMacSSid) );
1614 roamTS2 = vos_timer_get_system_time();
1615 pAdjRep->tsmRoamdelay = roamTS2 - pSession->roamTS1;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001616 pAdjRep->roamReason =SIR_ESE_ASSOC_REASON_UNSPECIFIED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 pAdjRep->clientDissSecs =(pAdjRep->tsmRoamdelay/1000);
1618
1619 palSendMBMessage(pMac->hHdd, pAdjRep);
1620
1621 return;
1622}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001623#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001624#endif