blob: ae5c5d7650cf228dd264f14501de4eb0d5ac1bed [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Agrawal Ashish01c66342017-01-27 12:52:25 +05302 * Copyright (c) 2012-2015, 2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -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.
20 */
Gopichand Nakkalac6c91902013-05-29 18:53:35 +053021
Kiet Lam842dad02014-02-18 18:44:02 -080022/*
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 */
Gopichand Nakkalac6c91902013-05-29 18:53:35 +053027
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**=========================================================================
29
30 \file rrmApi.c
31
32 \brief implementation for PE RRM APIs
33
Jeff Johnson295189b2012-06-20 16:38:30 -070034
35 ========================================================================*/
36
37/* $Header$ */
38
39#if defined WLAN_FEATURE_VOWIFI
40
41/*--------------------------------------------------------------------------
42 Include Files
43 ------------------------------------------------------------------------*/
44#include "palTypes.h"
45#include "wniApi.h"
46#include "sirApi.h"
47#include "aniGlobal.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053048#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070049#include "limTypes.h"
50#include "limUtils.h"
51#include "limSendSmeRspMessages.h"
52#include "parserApi.h"
53#include "limSendMessages.h"
54#include "rrmGlobal.h"
55#include "rrmApi.h"
56
Gopichand Nakkala41b56fd2013-02-28 15:26:52 +053057tANI_U8
DARAM SUDHA588ae872013-12-08 07:54:56 +053058rrmGetMinOfMaxTxPower(tpAniSirGlobal pMac,
59 tPowerdBm regMax, tPowerdBm apTxPower)
Gopichand Nakkala41b56fd2013-02-28 15:26:52 +053060{
61 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +053062 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Gopichand Nakkala41b56fd2013-02-28 15:26:52 +053063 if((txPower >= RRM_MIN_TX_PWR_CAP) && (txPower <= RRM_MAX_TX_PWR_CAP))
64 maxTxPower = txPower;
65 else if (txPower < RRM_MIN_TX_PWR_CAP)
66 maxTxPower = RRM_MIN_TX_PWR_CAP;
67 else
68 maxTxPower = RRM_MAX_TX_PWR_CAP;
69
DARAM SUDHA588ae872013-12-08 07:54:56 +053070 limLog( pMac, LOG3,
71 "%s: regulatoryMax = %d, apTxPwr = %d, maxTxpwr = %d",
72 __func__, regMax, apTxPower, maxTxPower );
Gopichand Nakkala41b56fd2013-02-28 15:26:52 +053073 return maxTxPower;
74}
Jeff Johnson295189b2012-06-20 16:38:30 -070075
76// --------------------------------------------------------------------
77/**
78 * rrmCacheMgmtTxPower
79 **
80 * FUNCTION: Store Tx power for management frames.
81 *
82 * LOGIC:
83 *
84 * ASSUMPTIONS:
85 *
86 * NOTE:
87 *
88 * @param pSessionEntry session entry.
89 * @return None
90 */
91void
92rrmCacheMgmtTxPower ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
93{
DARAM SUDHA588ae872013-12-08 07:54:56 +053094 limLog( pMac, LOG3, "Cache Mgmt Tx Power = %d", txPower );
95
Jeff Johnson295189b2012-06-20 16:38:30 -070096 if( pSessionEntry == NULL )
DARAM SUDHA588ae872013-12-08 07:54:56 +053097 {
98 limLog( pMac, LOG3, "%s: pSessionEntry is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070099 pMac->rrm.rrmPEContext.txMgmtPower = txPower;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530100 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700101 else
102 pSessionEntry->txMgmtPower = txPower;
103}
104
105// --------------------------------------------------------------------
106/**
107 * rrmGetMgmtTxPower
108 *
109 * FUNCTION: Get the Tx power for management frames.
110 *
111 * LOGIC:
112 *
113 * ASSUMPTIONS:
114 *
115 * NOTE:
116 *
117 * @param pSessionEntry session entry.
118 * @return txPower
119 */
120tPowerdBm
121rrmGetMgmtTxPower ( tpAniSirGlobal pMac, tpPESession pSessionEntry )
122{
DARAM SUDHA588ae872013-12-08 07:54:56 +0530123 limLog( pMac, LOG3, "RrmGetMgmtTxPower called" );
124
Jeff Johnson295189b2012-06-20 16:38:30 -0700125 if( pSessionEntry == NULL )
DARAM SUDHA588ae872013-12-08 07:54:56 +0530126 {
DARAM SUDHA26e00272014-02-12 11:50:39 +0530127 limLog( pMac, LOG3, "%s: txpower from rrmPEContext: %d",
128 __func__, pMac->rrm.rrmPEContext.txMgmtPower);
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 return pMac->rrm.rrmPEContext.txMgmtPower;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530130 }
131
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 return pSessionEntry->txMgmtPower;
133}
134
135// --------------------------------------------------------------------
136/**
137 * rrmSendSetMaxTxPowerReq
138 *
139 * FUNCTION: Send WDA_SET_MAX_TX_POWER_REQ message to change the max tx power.
140 *
141 * LOGIC:
142 *
143 * ASSUMPTIONS:
144 *
145 * NOTE:
146 *
147 * @param txPower txPower to be set.
148 * @param pSessionEntry session entry.
149 * @return None
150 */
151tSirRetStatus
152rrmSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
153{
154 tpMaxTxPowerParams pMaxTxParams;
155 tSirRetStatus retCode = eSIR_SUCCESS;
156 tSirMsgQ msgQ;
157
158 if( pSessionEntry == NULL )
159 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700160 PELOGE(limLog(pMac, LOGE, FL(" Inavalid parameters"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 return eSIR_FAILURE;
162 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530163 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
164 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700166 limLog( pMac, LOGP, FL("Unable to allocate memory for pMaxTxParams ") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 return eSIR_MEM_ALLOC_FAILED;
168
169 }
DARAM SUDHA588ae872013-12-08 07:54:56 +0530170 /* Allocated memory for pMaxTxParams...will be freed in other module */
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530172 vos_mem_copy(pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr));
173 vos_mem_copy(pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700174
175
176 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
177 msgQ.reserved = 0;
178 msgQ.bodyptr = pMaxTxParams;
179 msgQ.bodyval = 0;
180
DARAM SUDHA588ae872013-12-08 07:54:56 +0530181 limLog(pMac, LOG3,
182 FL( "Sending WDA_SET_MAX_TX_POWER_REQ with power(%d) to HAL"),
183 txPower);
Jeff Johnson295189b2012-06-20 16:38:30 -0700184
Jeff Johnsone7245742012-09-05 17:12:55 -0700185 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
187 {
188 limLog( pMac, LOGP, FL("Posting WDA_SET_MAX_TX_POWER_REQ to HAL failed, reason=%X"), retCode );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530189 vos_mem_free(pMaxTxParams);
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 return retCode;
191 }
192 return retCode;
193}
194
195
196// --------------------------------------------------------------------
197/**
198 * rrmSetMaxTxPowerRsp
199 *
200 * FUNCTION: Process WDA_SET_MAX_TX_POWER_RSP message.
201 *
202 * LOGIC:
203 *
204 * ASSUMPTIONS:
205 *
206 * NOTE:
207 *
208 * @param txPower txPower to be set.
209 * @param pSessionEntry session entry.
210 * @return None
211 */
212tSirRetStatus
213rrmSetMaxTxPowerRsp ( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
214{
215 tSirRetStatus retCode = eSIR_SUCCESS;
216 tpMaxTxPowerParams pMaxTxParams = (tpMaxTxPowerParams) limMsgQ->bodyptr;
217 tpPESession pSessionEntry;
Venkata Prathyusha Kuntupalli74cd99f2013-05-09 16:50:39 -0700218 tANI_U8 sessionId, i;
219 tSirMacAddr bssid = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
Jeff Johnson295189b2012-06-20 16:38:30 -0700220
Kiet Lam842c3e12013-11-16 22:40:57 +0530221 if( vos_mem_compare(bssid, pMaxTxParams->bssId, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 {
Venkata Prathyusha Kuntupalli74cd99f2013-05-09 16:50:39 -0700223 for (i =0;i < pMac->lim.maxBssId;i++)
224 {
225 if ( (pMac->lim.gpSession[i].valid == TRUE ))
226 {
227 pSessionEntry = &pMac->lim.gpSession[i];
228 rrmCacheMgmtTxPower ( pMac, pMaxTxParams->power, pSessionEntry );
229 }
230 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 }
232 else
233 {
Venkata Prathyusha Kuntupalli74cd99f2013-05-09 16:50:39 -0700234 if((pSessionEntry = peFindSessionByBssid(pMac, pMaxTxParams->bssId, &sessionId))==NULL)
235 {
236 PELOGE(limLog(pMac, LOGE, FL("Unable to find session:") );)
237 retCode = eSIR_FAILURE;
238 }
239 else
240 {
241 rrmCacheMgmtTxPower ( pMac, pMaxTxParams->power, pSessionEntry );
242 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 }
244
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530245 vos_mem_free(limMsgQ->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700246 limMsgQ->bodyptr = NULL;
247 return retCode;
248}
249// --------------------------------------------------------------------
250/**
251 * rrmProcessLinkMeasurementRequest
252 *
253 * FUNCTION: Processes the Link measurement request and send the report.
254 *
255 * LOGIC:
256 *
257 * ASSUMPTIONS:
258 *
259 * NOTE:
260 *
261 * @param pBd pointer to BD to extract RSSI and SNR
262 * @param pLinkReq pointer to the Link request frame structure.
263 * @param pSessionEntry session entry.
264 * @return None
265 */
266tSirRetStatus
DARAM SUDHA588ae872013-12-08 07:54:56 +0530267rrmProcessLinkMeasurementRequest( tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -0700268 tANI_U8 *pRxPacketInfo,
269 tDot11fLinkMeasurementRequest *pLinkReq,
270 tpPESession pSessionEntry )
271{
272 tSirMacLinkReport LinkReport;
273 tpSirMacMgmtHdr pHdr;
274 v_S7_t currentRSSI = 0;
275
DARAM SUDHA588ae872013-12-08 07:54:56 +0530276 limLog( pMac, LOG3, "Received Link measurement request");
277
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 if( pRxPacketInfo == NULL || pLinkReq == NULL || pSessionEntry == NULL )
279 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530280 PELOGE(limLog( pMac, LOGE,
281 "%s Invalid parameters - Ignoring the request", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 return eSIR_FAILURE;
283 }
284 pHdr = WDA_GET_RX_MAC_HEADER( pRxPacketInfo );
Abhinav Kumar5deb9cd2018-05-10 11:04:59 +0530285 LinkReport.txPower = limGetMaxTxPower (pSessionEntry->def_max_tx_pwr,
Agrawal Ashish01c66342017-01-27 12:52:25 +0530286 pLinkReq->MaxTxPower.maxTxPower,
287 pMac->roam.configParam.nTxPowerCap);
Madan Mohan Koyyalamudiab675df2013-07-24 02:57:41 +0530288
Agrawal Ashish01c66342017-01-27 12:52:25 +0530289 if ((LinkReport.txPower != (uint8)(pSessionEntry->maxTxPower)) &&
290 (eSIR_SUCCESS == rrmSendSetMaxTxPowerReq (pMac,
291 (tPowerdBm)(LinkReport.txPower),
292 pSessionEntry)))
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530293 {
Agrawal Ashish01c66342017-01-27 12:52:25 +0530294 PELOGW (limLog (pMac,
295 LOGW,
296 FL(" maxTx power in link report is not same as local..."
297 " Local = %d Link Request TxPower = %d"
298 " Link Report TxPower = %d"),
299 pSessionEntry->maxTxPower,
300 LinkReport.txPower,
301 pLinkReq->MaxTxPower.maxTxPower);)
302 pSessionEntry->maxTxPower = (tPowerdBm)(LinkReport.txPower);
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530303 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 LinkReport.dialogToken = pLinkReq->DialogToken.token;
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 LinkReport.rxAntenna = 0;
306 LinkReport.txAntenna = 0;
307 currentRSSI = WDA_GET_RX_RSSI_DB(pRxPacketInfo);
308
DARAM SUDHA588ae872013-12-08 07:54:56 +0530309 limLog( pMac, LOG1,
310 "Received Link report frame with %d", currentRSSI);
Jeff Johnson295189b2012-06-20 16:38:30 -0700311
312 // 2008 11k spec reference: 18.4.8.5 RCPI Measurement
313 if ((currentRSSI) <= RCPI_LOW_RSSI_VALUE)
DARAM SUDHA588ae872013-12-08 07:54:56 +0530314 LinkReport.rcpi = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 else if ((currentRSSI > RCPI_LOW_RSSI_VALUE) && (currentRSSI <= 0))
316 LinkReport.rcpi = CALCULATE_RCPI(currentRSSI);
DARAM SUDHA588ae872013-12-08 07:54:56 +0530317 else
318 LinkReport.rcpi = RCPI_MAX_VALUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700319
DARAM SUDHA588ae872013-12-08 07:54:56 +0530320 LinkReport.rsni = WDA_GET_RX_SNR(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700321
DARAM SUDHA588ae872013-12-08 07:54:56 +0530322 limLog( pMac, LOG3, "Sending Link report frame");
Jeff Johnson295189b2012-06-20 16:38:30 -0700323
DARAM SUDHA588ae872013-12-08 07:54:56 +0530324 return limSendLinkReportActionFrame( pMac, &LinkReport, pHdr->sa, pSessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700325}
326
327// --------------------------------------------------------------------
328/**
329 * rrmProcessNeighborReportResponse
330 *
331 * FUNCTION: Processes the Neighbor Report response from the peer AP.
332 *
333 * LOGIC:
334 *
335 * ASSUMPTIONS:
336 *
337 * NOTE:
338 *
339 * @param pNeighborRep pointer to the Neighbor report frame structure.
340 * @param pSessionEntry session entry.
341 * @return None
342 */
343tSirRetStatus
344rrmProcessNeighborReportResponse( tpAniSirGlobal pMac,
345 tDot11fNeighborReportResponse *pNeighborRep,
346 tpPESession pSessionEntry )
347{
348 tSirRetStatus status = eSIR_FAILURE;
349 tpSirNeighborReportInd pSmeNeighborRpt = NULL;
350 tANI_U16 length;
351 tANI_U8 i;
352 tSirMsgQ mmhMsg;
353
354 if( pNeighborRep == NULL || pSessionEntry == NULL )
355 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700356 PELOGE(limLog( pMac, LOGE, FL(" Invalid parameters") );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 return status;
358 }
359
DARAM SUDHA588ae872013-12-08 07:54:56 +0530360 limLog( pMac, LOG3, FL("Neighbor report response received ") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700361
362 // Dialog token
363 if( pMac->rrm.rrmPEContext.DialogToken != pNeighborRep->DialogToken.token )
364 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530365 PELOGE(limLog( pMac, LOGE,
366 "Dialog token mismatch in the received Neighbor report");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 return eSIR_FAILURE;
368 }
369 if( pNeighborRep->num_NeighborReport == 0 )
370 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700371 PELOGE(limLog( pMac, LOGE, "No neighbor report in the frame...Dropping it");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 return eSIR_FAILURE;
373 }
374 length = (sizeof( tSirNeighborReportInd )) +
DARAM SUDHA588ae872013-12-08 07:54:56 +0530375 (sizeof( tSirNeighborBssDescription ) * (pNeighborRep->num_NeighborReport - 1) ) ;
376
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 //Prepare the request to send to SME.
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530378 pSmeNeighborRpt = vos_mem_malloc(length);
379 if( NULL == pSmeNeighborRpt )
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700381 PELOGE(limLog( pMac, LOGP, FL("Unable to allocate memory") );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 return eSIR_MEM_ALLOC_FAILED;
383
384 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530385 vos_mem_set(pSmeNeighborRpt, length, 0);
DARAM SUDHA588ae872013-12-08 07:54:56 +0530386
387 /* Allocated memory for pSmeNeighborRpt...will be freed by other module */
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
389 for( i = 0 ; i < pNeighborRep->num_NeighborReport ; i++ )
390 {
391 pSmeNeighborRpt->sNeighborBssDescription[i].length = sizeof( tSirNeighborBssDescription ); /*+ any optional ies */
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530392 vos_mem_copy(pSmeNeighborRpt->sNeighborBssDescription[i].bssId,
393 pNeighborRep->NeighborReport[i].bssid,
394 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fApPreauthReachable = pNeighborRep->NeighborReport[i].APReachability;
396 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fSameSecurityMode = pNeighborRep->NeighborReport[i].Security;
397 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fSameAuthenticator = pNeighborRep->NeighborReport[i].KeyScope;
398 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapSpectrumMeasurement = pNeighborRep->NeighborReport[i].SpecMgmtCap;
399 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapQos = pNeighborRep->NeighborReport[i].QosCap;
400 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapApsd = pNeighborRep->NeighborReport[i].apsd;
401 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapRadioMeasurement = pNeighborRep->NeighborReport[i].rrm;
402 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapDelayedBlockAck = pNeighborRep->NeighborReport[i].DelayedBA;
403 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapImmediateBlockAck = pNeighborRep->NeighborReport[i].ImmBA;
404 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fMobilityDomain = pNeighborRep->NeighborReport[i].MobilityDomain;
405
406 pSmeNeighborRpt->sNeighborBssDescription[i].regClass = pNeighborRep->NeighborReport[i].regulatoryClass;
407 pSmeNeighborRpt->sNeighborBssDescription[i].channel = pNeighborRep->NeighborReport[i].channel;
408 pSmeNeighborRpt->sNeighborBssDescription[i].phyType = pNeighborRep->NeighborReport[i].PhyType;
409 }
410
411 pSmeNeighborRpt->messageType = eWNI_SME_NEIGHBOR_REPORT_IND;
412 pSmeNeighborRpt->length = length;
413 pSmeNeighborRpt->numNeighborReports = pNeighborRep->num_NeighborReport;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530414 vos_mem_copy(pSmeNeighborRpt->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700415
416 //Send request to SME.
417 mmhMsg.type = pSmeNeighborRpt->messageType;
418 mmhMsg.bodyptr = pSmeNeighborRpt;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +0530419 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, pSessionEntry->peSessionId,
420 mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 status = limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
422
423 return status;
424
425}
426
427// --------------------------------------------------------------------
428/**
429 * rrmProcessNeighborReportReq
430 *
DARAM SUDHA588ae872013-12-08 07:54:56 +0530431 * FUNCTION:
Jeff Johnson295189b2012-06-20 16:38:30 -0700432 *
433 * LOGIC: Create a Neighbor report request and send it to peer.
434 *
435 * ASSUMPTIONS:
436 *
437 * NOTE:
438 *
439 * @param pNeighborReq Neighbor report request params .
440 * @return None
441 */
442tSirRetStatus
443rrmProcessNeighborReportReq( tpAniSirGlobal pMac,
444 tpSirNeighborReportReqInd pNeighborReq )
445{
446 tSirRetStatus status = eSIR_SUCCESS;
447 tSirMacNeighborReportReq NeighborReportReq;
448 tpPESession pSessionEntry ;
449 tANI_U8 sessionId;
450
451 if( pNeighborReq == NULL )
452 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700453 PELOGE(limLog( pMac, LOGE, "NeighborReq is NULL" );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 return eSIR_FAILURE;
455 }
456 if ((pSessionEntry = peFindSessionByBssid(pMac,pNeighborReq->bssId,&sessionId))==NULL)
457 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700458 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 return eSIR_FAILURE;
460 }
461
DARAM SUDHA588ae872013-12-08 07:54:56 +0530462 limLog( pMac, LOG1, FL("SSID present = %d "), pNeighborReq->noSSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700463
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530464 vos_mem_set(&NeighborReportReq,sizeof( tSirMacNeighborReportReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700465
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700466 NeighborReportReq.dialogToken = ++pMac->rrm.rrmPEContext.DialogToken;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530467 NeighborReportReq.ssid_present = !pNeighborReq->noSSID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 if( NeighborReportReq.ssid_present )
469 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530470 vos_mem_copy(&NeighborReportReq.ssid, &pNeighborReq->ucSSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 PELOGE(sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGE, (tANI_U8*) NeighborReportReq.ssid.ssId, NeighborReportReq.ssid.length );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 }
473
474 status = limSendNeighborReportRequestFrame( pMac, &NeighborReportReq, pNeighborReq->bssId, pSessionEntry );
475
476 return status;
477}
478
479#define ABS(x) ((x < 0) ? -x : x)
480// --------------------------------------------------------------------
481/**
482 * rrmProcessBeaconReportReq
483 *
484 * FUNCTION: Processes the Beacon report request from the peer AP.
485 *
486 * LOGIC:
487 *
488 * ASSUMPTIONS:
489 *
490 * NOTE:
491 *
492 * @param pCurrentReq pointer to the current Req comtext.
493 * @param pBeaconReq pointer to the beacon report request IE from the peer.
494 * @param pSessionEntry session entry.
495 * @return None
496 */
497static tRrmRetStatus
DARAM SUDHA588ae872013-12-08 07:54:56 +0530498rrmProcessBeaconReportReq( tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 tpRRMReq pCurrentReq,
500 tDot11fIEMeasurementRequest *pBeaconReq,
501 tpPESession pSessionEntry )
502{
503 tSirMsgQ mmhMsg;
504 tpSirBeaconReportReqInd pSmeBcnReportReq;
505 tANI_U8 num_channels = 0, num_APChanReport;
506 tANI_U16 measDuration, maxMeasduration;
507 tANI_S8 maxDuration;
508 tANI_U8 sign;
509
DARAM SUDHA588ae872013-12-08 07:54:56 +0530510 if( pBeaconReq->measurement_request.Beacon.BeaconReporting.present &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 (pBeaconReq->measurement_request.Beacon.BeaconReporting.reportingCondition != 0) )
512 {
513 //Repeated measurement is not supported. This means number of repetitions should be zero.(Already checked)
514 //All test case in VoWifi(as of version 0.36) use zero for number of repetitions.
515 //Beacon reporting should not be included in request if number of repetitons is zero.
516 // IEEE Std 802.11k-2008 Table 7-29g and section 11.10.8.1
517
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700518 PELOGE(limLog( pMac, LOGE, "Dropping the request: Reporting condition included in beacon report request and it is not zero");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 return eRRM_INCAPABLE;
520 }
521
522 /* The logic here is to check the measurement duration passed in the beacon request. Following are the cases handled.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530523 Case 1: If measurement duration received in the beacon request is greater than the max measurement duration advertised
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 in the RRM capabilities(Assoc Req), and Duration Mandatory bit is set to 1, REFUSE the beacon request
DARAM SUDHA588ae872013-12-08 07:54:56 +0530525 Case 2: If measurement duration received in the beacon request is greater than the max measurement duration advertised
526 in the RRM capabilities(Assoc Req), and Duration Mandatory bit is set to 0, perform measurement for
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 the duration advertised in the RRM capabilities
DARAM SUDHA588ae872013-12-08 07:54:56 +0530528
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 maxMeasurementDuration = 2^(nonOperatingChanMax - 4) * BeaconInterval
530 */
531 maxDuration = pMac->rrm.rrmPEContext.rrmEnabledCaps.nonOperatingChanMax - 4;
532 sign = (maxDuration < 0) ? 1 : 0;
533 maxDuration = (1L << ABS(maxDuration));
534 if (!sign)
535 maxMeasduration = maxDuration * pSessionEntry->beaconParams.beaconInterval;
536 else
537 maxMeasduration = pSessionEntry->beaconParams.beaconInterval / maxDuration;
538
DARAM SUDHA588ae872013-12-08 07:54:56 +0530539 measDuration = pBeaconReq->measurement_request.Beacon.meas_duration;
Jeff Johnson295189b2012-06-20 16:38:30 -0700540
DARAM SUDHA588ae872013-12-08 07:54:56 +0530541 limLog( pMac, LOG3,
542 "maxDuration = %d sign = %d maxMeasduration = %d measDuration = %d",
543 maxDuration, sign, maxMeasduration, measDuration );
Jeff Johnson295189b2012-06-20 16:38:30 -0700544
545 if( maxMeasduration < measDuration )
546 {
547 if( pBeaconReq->durationMandatory )
548 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530549 PELOGE(limLog( pMac, LOGE, "Dropping the request: duration mandatory and maxduration > measduration");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 return eRRM_REFUSED;
551 }
552 else
553 measDuration = maxMeasduration;
554 }
555
556 //Cache the data required for sending report.
557 pCurrentReq->request.Beacon.reportingDetail = pBeaconReq->measurement_request.Beacon.BcnReportingDetail.present ?
558 pBeaconReq->measurement_request.Beacon.BcnReportingDetail.reportingDetail :
559 BEACON_REPORTING_DETAIL_ALL_FF_IE ;
560
561 if( pBeaconReq->measurement_request.Beacon.RequestedInfo.present )
562 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530563 pCurrentReq->request.Beacon.reqIes.pElementIds = vos_mem_malloc(sizeof(tANI_U8) *
564 pBeaconReq->measurement_request.Beacon.RequestedInfo.num_requested_eids);
565 if ( NULL == pCurrentReq->request.Beacon.reqIes.pElementIds )
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 {
567 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530568 FL( "Unable to allocate memory for request IEs buffer" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 return eRRM_FAILURE;
570 }
DARAM SUDHA588ae872013-12-08 07:54:56 +0530571 limLog( pMac, LOG3, FL(" Allocated memory for pElementIds") );
572
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 pCurrentReq->request.Beacon.reqIes.num = pBeaconReq->measurement_request.Beacon.RequestedInfo.num_requested_eids;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530574 vos_mem_copy(pCurrentReq->request.Beacon.reqIes.pElementIds,
575 pBeaconReq->measurement_request.Beacon.RequestedInfo.requested_eids,
576 pCurrentReq->request.Beacon.reqIes.num);
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 }
578
579 if( pBeaconReq->measurement_request.Beacon.num_APChannelReport )
580 {
581 for( num_APChanReport = 0 ; num_APChanReport < pBeaconReq->measurement_request.Beacon.num_APChannelReport ; num_APChanReport++ )
582 num_channels += pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList;
583 }
584
585 //Prepare the request to send to SME.
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800586 pSmeBcnReportReq = vos_mem_malloc(sizeof( tSirBeaconReportReqInd ));
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530587 if ( NULL == pSmeBcnReportReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 {
589 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530590 FL( "Unable to allocate memory during Beacon Report Req Ind to SME" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
592 return eRRM_FAILURE;
593
594 }
595
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800596 vos_mem_set(pSmeBcnReportReq,sizeof( tSirBeaconReportReqInd ),0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700597
DARAM SUDHA588ae872013-12-08 07:54:56 +0530598 /* Allocated memory for pSmeBcnReportReq....will be freed by other modulea*/
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530599 vos_mem_copy(pSmeBcnReportReq->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800601 pSmeBcnReportReq->length = sizeof( tSirBeaconReportReqInd );
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 pSmeBcnReportReq->uDialogToken = pBeaconReq->measurement_token;
Kanchanapally, Vidyullatha5dbeaf22014-03-05 20:18:33 +0530603 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_11K;
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 pSmeBcnReportReq->randomizationInterval = SYS_TU_TO_MS (pBeaconReq->measurement_request.Beacon.randomization);
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 pSmeBcnReportReq->channelInfo.regulatoryClass = pBeaconReq->measurement_request.Beacon.regClass;
606 pSmeBcnReportReq->channelInfo.channelNum = pBeaconReq->measurement_request.Beacon.channel;
Kanchanapally, Vidyullatha5dbeaf22014-03-05 20:18:33 +0530607 pSmeBcnReportReq->measurementDuration[0] = SYS_TU_TO_MS(measDuration);
608 pSmeBcnReportReq->fMeasurementtype[0] = pBeaconReq->measurement_request.Beacon.meas_mode;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530609 vos_mem_copy(pSmeBcnReportReq->macaddrBssid, pBeaconReq->measurement_request.Beacon.BSSID,
610 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700611
612 if( pBeaconReq->measurement_request.Beacon.SSID.present )
613 {
614 pSmeBcnReportReq->ssId.length = pBeaconReq->measurement_request.Beacon.SSID.num_ssid;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530615 vos_mem_copy(pSmeBcnReportReq->ssId.ssId,
616 pBeaconReq->measurement_request.Beacon.SSID.ssid,
617 pSmeBcnReportReq->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 }
619
620 pCurrentReq->token = pBeaconReq->measurement_token;
621
622 pSmeBcnReportReq->channelList.numChannels = num_channels;
623 if( pBeaconReq->measurement_request.Beacon.num_APChannelReport )
624 {
Nishank Aggarwal20182682017-06-27 12:24:19 +0530625 tANI_U8 *ch_lst = pSmeBcnReportReq->channelList.channelNumber;
626 tANI_U8 len;
627 tANI_U16 ch_ctr = 0;
628 for(num_APChanReport = 0;
629 num_APChanReport <
630 pBeaconReq->measurement_request.Beacon.num_APChannelReport;
631 num_APChanReport++) {
632 len = pBeaconReq->measurement_request.Beacon.
633 APChannelReport[num_APChanReport].num_channelList;
634 if (ch_ctr + len >
635 sizeof(pSmeBcnReportReq->channelList.channelNumber))
636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700637
Nishank Aggarwal20182682017-06-27 12:24:19 +0530638 vos_mem_copy(&ch_lst[ch_ctr],
639 pBeaconReq->measurement_request.Beacon.
640 APChannelReport[num_APChanReport].channelList,
641 len);
642
643 ch_ctr += len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 }
645 }
646
647 //Send request to SME.
648 mmhMsg.type = eWNI_SME_BEACON_REPORT_REQ_IND;
649 mmhMsg.bodyptr = pSmeBcnReportReq;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +0530650 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, pSessionEntry->peSessionId,
651 mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700652 return limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
653}
654
655// --------------------------------------------------------------------
656/**
657 * rrmFillBeaconIes
658 *
DARAM SUDHA588ae872013-12-08 07:54:56 +0530659 * FUNCTION:
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 *
661 * LOGIC: Fills Fixed fields and Ies in bss description to an array of tANI_U8.
662 *
663 * ASSUMPTIONS:
664 *
665 * NOTE:
666 *
667 * @param pIes - pointer to the buffer that should be populated with ies.
668 * @param pNumIes - returns the num of ies filled in this param.
669 * @param pIesMaxSize - Max size of the buffer pIes.
670 * @param eids - pointer to array of eids. If NULL, all ies will be populated.
671 * @param numEids - number of elements in array eids.
672 * @param pBssDesc - pointer to Bss Description.
673 * @return None
674 */
675static void
DARAM SUDHA588ae872013-12-08 07:54:56 +0530676rrmFillBeaconIes( tpAniSirGlobal pMac,
677 tANI_U8 *pIes, tANI_U8 *pNumIes, tANI_U8 pIesMaxSize,
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 tANI_U8 *eids, tANI_U8 numEids,
679 tpSirBssDescription pBssDesc )
680{
Pragaspathi Thilagaraja3d700f2020-02-12 16:07:38 +0530681 tANI_U8 len, *pBcnIes, count = 0, i;
682 tANI_U16 BcnNumIes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700683
684 if( (pIes == NULL) || (pNumIes == NULL) || (pBssDesc == NULL) )
685 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700686 PELOGE(limLog( pMac, LOGE, FL(" Invalid parameters") );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 return;
688 }
689
690 //Make sure that if eid is null, numEids is set to zero.
691 numEids = (eids == NULL) ? 0 : numEids;
692
693 pBcnIes = (tANI_U8*) &pBssDesc->ieFields[0];
694 BcnNumIes = (tANI_U8)GET_IE_LEN_IN_BSS( pBssDesc->length );
695
696 *pNumIes = 0;
697
698 *((tANI_U32*)pIes) = pBssDesc->timeStamp[0];
699 *pNumIes+=sizeof(tANI_U32); pIes+=sizeof(tANI_U32);
700 *((tANI_U32*)pIes) = pBssDesc->timeStamp[1];
701 *pNumIes+=sizeof(tANI_U32); pIes+=sizeof(tANI_U32);
702 *((tANI_U16*)pIes) = pBssDesc->beaconInterval;
703 *pNumIes+=sizeof(tANI_U16); pIes+=sizeof(tANI_U16);
704 *((tANI_U16*)pIes) = pBssDesc->capabilityInfo;
705 *pNumIes+=sizeof(tANI_U16); pIes+=sizeof(tANI_U16);
706
sheenam mongabf883a92020-03-11 15:34:39 +0530707 while ( BcnNumIes >= 2 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 {
Pragaspathi Thilagaraja3d700f2020-02-12 16:07:38 +0530709 len = *(pBcnIes + 1); //element id + length.
710 len += 2;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530711 limLog( pMac, LOG3, "EID = %d, len = %d total = %d",
712 *pBcnIes, *(pBcnIes+1), len );
Jeff Johnson295189b2012-06-20 16:38:30 -0700713
Pragaspathi Thilagaraja3d700f2020-02-12 16:07:38 +0530714 if (BcnNumIes < len || len <= 2) {
715 limLog(pMac, LOGE, "RRM: Invalid IE len:%d exp_len:%d",
716 len, BcnNumIes);
717 break;
718 }
719
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 i = 0;
721 do
DARAM SUDHA588ae872013-12-08 07:54:56 +0530722 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 if( ( (eids == NULL) || ( *pBcnIes == eids[i] ) ) &&
724 ( (*pNumIes) + len) < pIesMaxSize )
725 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530726 limLog( pMac, LOG3, "Adding Eid %d, len=%d", *pBcnIes, len );
727
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530728 vos_mem_copy(pIes, pBcnIes, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 pIes += len;
730 *pNumIes += len;
731 count++;
732 break;
733 }
734 i++;
735 }while( i < numEids );
736
737 pBcnIes += len;
738 BcnNumIes -= len;
739 }
DARAM SUDHA588ae872013-12-08 07:54:56 +0530740 limLog( pMac, LOG1, "Total length of Ies added = %d", *pNumIes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700741}
DARAM SUDHA588ae872013-12-08 07:54:56 +0530742
Jeff Johnson295189b2012-06-20 16:38:30 -0700743// --------------------------------------------------------------------
744/**
745 * rrmProcessBeaconReportXmit
746 *
DARAM SUDHA588ae872013-12-08 07:54:56 +0530747 * FUNCTION:
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 *
749 * LOGIC: Create a Radio measurement report action frame and send it to peer.
750 *
751 * ASSUMPTIONS:
752 *
753 * NOTE:
754 *
755 * @param pBcnReport Data for beacon report IE from SME.
756 * @return None
757 */
758tSirRetStatus
759rrmProcessBeaconReportXmit( tpAniSirGlobal pMac,
760 tpSirBeaconReportXmitInd pBcnReport)
761{
762 tSirRetStatus status = eSIR_SUCCESS;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530763 tSirMacRadioMeasureReport *pReport = NULL;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530764 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 tpPESession pSessionEntry ;
766 tANI_U8 sessionId;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530767 v_U8_t flagBSSPresent = FALSE, bssDescCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700768
DARAM SUDHA588ae872013-12-08 07:54:56 +0530769 limLog( pMac, LOG1, "Received beacon report xmit indication");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530770
771 if (NULL == pBcnReport)
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530773 PELOGE(limLog( pMac, LOGE,
774 "Received pBcnReport is NULL in PE");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 return eSIR_FAILURE;
776 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530777
778 if (NULL == pCurrentReq)
779 {
780 PELOGE(limLog( pMac, LOGE,
781 "Received report xmit while there is no request pending in PE");)
782 return eSIR_FAILURE;
783 }
784
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530785 if( (pBcnReport->numBssDesc) ||
786 (!pBcnReport->numBssDesc && pCurrentReq->sendEmptyBcnRpt) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 {
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530788 pBcnReport->numBssDesc = (pBcnReport->numBssDesc == RRM_BCN_RPT_NO_BSS_INFO)?
789 RRM_BCN_RPT_MIN_RPT : pBcnReport->numBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700790
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530791 if (NULL == (pSessionEntry = peFindSessionByBssid(pMac,
792 pBcnReport->bssId,
793 &sessionId)))
794 {
795 PELOGE(limLog(pMac, LOGE, FL("session does not exist for given bssId"));)
796 return eSIR_FAILURE;
797 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700798
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530799 pReport = vos_mem_malloc(pBcnReport->numBssDesc *
800 sizeof(tSirMacRadioMeasureReport));
Jeff Johnson295189b2012-06-20 16:38:30 -0700801
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530802 if (NULL == pReport)
803 {
804 PELOGE(limLog(pMac, LOGE, FL("RRM Report is NULL, allocation failed"));)
805 return eSIR_FAILURE;
806 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530807
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530808 vos_mem_zero( pReport,
809 pBcnReport->numBssDesc * sizeof(tSirMacRadioMeasureReport) );
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530810
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530811 for (bssDescCnt = 0; bssDescCnt < pBcnReport->numBssDesc; bssDescCnt++)
812 {
813 //Prepare the beacon report and send it to the peer.
814 pReport[bssDescCnt].token = pBcnReport->uDialogToken;
815 pReport[bssDescCnt].refused = 0;
816 pReport[bssDescCnt].incapable = 0;
817 pReport[bssDescCnt].type = SIR_MAC_RRM_BEACON_TYPE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700818
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530819 //If the scan result is NULL then send report request with
820 //option subelement as NULL..
821 if ( NULL != pBcnReport->pBssDescription[bssDescCnt] )
822 {
823 flagBSSPresent = TRUE;
824 }
825
826 //Valid response is included if the size of beacon xmit
827 //is == size of beacon xmit ind + ies
828 if ( pBcnReport->length >= sizeof( tSirBeaconReportXmitInd ) )
829 {
830 pReport[bssDescCnt].report.beaconReport.regClass = pBcnReport->regClass;
831 if ( flagBSSPresent )
832 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530833 pReport[bssDescCnt].report.beaconReport.channel =
834 pBcnReport->pBssDescription[bssDescCnt]->channelId;
835 vos_mem_copy( pReport[bssDescCnt].report.beaconReport.measStartTime,
836 pBcnReport->pBssDescription[bssDescCnt]->startTSF,
837 sizeof( pBcnReport->pBssDescription[bssDescCnt]->startTSF) );
838 pReport[bssDescCnt].report.beaconReport.measDuration =
839 SYS_MS_TO_TU(pBcnReport->duration);
840 pReport[bssDescCnt].report.beaconReport.phyType =
841 pBcnReport->pBssDescription[bssDescCnt]->nwType;
842 pReport[bssDescCnt].report.beaconReport.bcnProbeRsp = 1;
843 pReport[bssDescCnt].report.beaconReport.rsni =
844 pBcnReport->pBssDescription[bssDescCnt]->sinr;
845 pReport[bssDescCnt].report.beaconReport.rcpi =
846 pBcnReport->pBssDescription[bssDescCnt]->rssi;
847
848 pReport[bssDescCnt].report.beaconReport.antennaId = 0;
849 pReport[bssDescCnt].report.beaconReport.parentTSF =
850 pBcnReport->pBssDescription[bssDescCnt]->parentTSF;
851 vos_mem_copy( pReport[bssDescCnt].report.beaconReport.bssid,
852 pBcnReport->pBssDescription[bssDescCnt]->bssId,
853 sizeof(tSirMacAddr));
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530854 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530855
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530856 switch ( pCurrentReq->request.Beacon.reportingDetail )
857 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530858 case BEACON_REPORTING_DETAIL_NO_FF_IE:
859 //0 No need to include any elements.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530860 limLog(pMac, LOG3, "No reporting detail requested");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530861 break;
862 case BEACON_REPORTING_DETAIL_ALL_FF_REQ_IE:
863 //1: Include all FFs and Requested Ies.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530864 limLog(pMac, LOG3,
865 "Only requested IEs in reporting detail requested");
Jeff Johnson295189b2012-06-20 16:38:30 -0700866
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530867 if ( flagBSSPresent )
868 {
869 rrmFillBeaconIes( pMac,
870 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.Ies[0],
871 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.numIes,
872 BEACON_REPORT_MAX_IES,
873 pCurrentReq->request.Beacon.reqIes.pElementIds,
874 pCurrentReq->request.Beacon.reqIes.num,
875 pBcnReport->pBssDescription[bssDescCnt] );
876 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700877
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530878 break;
879 case BEACON_REPORTING_DETAIL_ALL_FF_IE:
880 //2 / default - Include all FFs and all Ies.
881 default:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530882 limLog(pMac, LOG3, "Default all IEs and FFs");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530883 if ( flagBSSPresent )
884 {
885 rrmFillBeaconIes( pMac,
886 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.Ies[0],
887 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.numIes,
888 BEACON_REPORT_MAX_IES,
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530889 NULL, 0,
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530890 pBcnReport->pBssDescription[bssDescCnt] );
891 }
892 break;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530893 }
894 }
895 }
896
897 limLog( pMac, LOG1, "Sending Action frame with %d bss info", bssDescCnt);
898 limSendRadioMeasureReportActionFrame( pMac,
899 pCurrentReq->dialog_token,
900 bssDescCnt,
901 pReport,
902 pBcnReport->bssId,
903 pSessionEntry );
904
905 pCurrentReq->sendEmptyBcnRpt = false;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530906 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700907
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 if( pBcnReport->fMeasureDone )
909 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530910 limLog( pMac, LOG3, "Measurement done....cleanup the context");
Jeff Johnson295189b2012-06-20 16:38:30 -0700911
912 rrmCleanup(pMac);
913 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530914
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530915 if( NULL != pReport )
916 vos_mem_free(pReport);
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 return status;
919}
920
DARAM SUDHA588ae872013-12-08 07:54:56 +0530921void rrmProcessBeaconRequestFailure(tpAniSirGlobal pMac, tpPESession pSessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 tSirMacAddr peer, tRrmRetStatus status)
923{
924 tpSirMacRadioMeasureReport pReport = NULL;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530925 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700926
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530927 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
928 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 {
930 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530931 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 return;
933 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530934 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 pReport->token = pCurrentReq->token;
936 pReport->type = SIR_MAC_RRM_BEACON_TYPE;
937
938 switch (status)
939 {
940 case eRRM_REFUSED:
941 pReport->refused = 1;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530942 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 case eRRM_INCAPABLE:
944 pReport->incapable = 1;
945 break;
946 default:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530947 PELOGE(limLog( pMac, LOGE,
948 FL(" Beacon request processing failed no report sent with status %d "),
949 status););
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530950 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 return;
952 }
953
DARAM SUDHA588ae872013-12-08 07:54:56 +0530954 limSendRadioMeasureReportActionFrame( pMac, pCurrentReq->dialog_token, 1,
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 pReport, peer, pSessionEntry );
956
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530957 vos_mem_free(pReport);
DARAM SUDHA588ae872013-12-08 07:54:56 +0530958 limLog( pMac, LOG3, FL(" Free memory for pReport") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 return;
960}
961
962// --------------------------------------------------------------------
963/**
964 * rrmProcessRadioMeasurementRequest
965 *
966 * FUNCTION: Processes the Radio Resource Measurement request.
967 *
968 * LOGIC:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970
971*
972 * ASSUMPTIONS:
973 *
974 * NOTE:
975 *
976 * @param peer Macaddress of the peer requesting the radio measurement.
977 * @param pRRMReq Array of Measurement request IEs
978 * @param pSessionEntry session entry.
979 * @return None
980 */
981tSirRetStatus
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530982rrmProcessRadioMeasurementRequest( tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 tSirMacAddr peer,
984 tDot11fRadioMeasurementRequest *pRRMReq,
985 tpPESession pSessionEntry )
986{
987 tANI_U8 i;
988 tSirRetStatus status = eSIR_SUCCESS;
989 tpSirMacRadioMeasureReport pReport = NULL;
990 tANI_U8 num_report = 0;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530991 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 tRrmRetStatus rrmStatus = eRRM_SUCCESS;
993
994 if( !pRRMReq->num_MeasurementRequest )
995 {
996 //No measurement requests....
997 //
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530998 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
999 if ( NULL == pReport )
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05301000 {
1001 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301002 FL( "Unable to allocate memory during RRM Req processing" ));
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05301003 return eSIR_MEM_ALLOC_FAILED;
1004 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301005 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport),0);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301006 PELOGE(limLog( pMac, LOGE,
1007 FL("No requestIes in the measurement request, sending incapable report"));)
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05301008 pReport->incapable = 1;
1009 num_report = 1;
1010 limSendRadioMeasureReportActionFrame( pMac, pRRMReq->DialogToken.token, num_report,
1011 pReport, peer, pSessionEntry );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301012 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 return eSIR_FAILURE;
1014 }
1015
1016 // PF Fix
1017 if( pRRMReq->NumOfRepetitions.repetitions > 0 )
1018 {
DARAM SUDHA588ae872013-12-08 07:54:56 +05301019 limLog( pMac, LOG1,
1020 FL(" number of repetitions %d"),
1021 pRRMReq->NumOfRepetitions.repetitions );
1022
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 //Send a report with incapable bit set. Not supporting repetitions.
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301024 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
1025 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 {
1027 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301028 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 return eSIR_MEM_ALLOC_FAILED;
1030 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301031 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport), 0);
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001032 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pReport") );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 pReport->incapable = 1;
1034 pReport->type = pRRMReq->MeasurementRequest[0].measurement_type;
1035 num_report = 1;
1036 goto end;
1037
1038 }
1039
1040 for( i= 0; i < pRRMReq->num_MeasurementRequest; i++ )
1041 {
1042 switch( pRRMReq->MeasurementRequest[i].measurement_type )
1043 {
1044 case SIR_MAC_RRM_BEACON_TYPE:
1045 //Process beacon request.
1046 if( pCurrentReq )
1047 {
1048 if ( pReport == NULL ) //Allocate memory to send reports for any subsequent requests.
1049 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301050 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport )
1051 * (pRRMReq->num_MeasurementRequest - i));
1052 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 {
1054 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301055 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 return eSIR_MEM_ALLOC_FAILED;
1057 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301058 vos_mem_set(pReport,
1059 sizeof( tSirMacRadioMeasureReport )
1060 * (pRRMReq->num_MeasurementRequest - i),
1061 0);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301062 limLog( pMac, LOG3,
1063 FL(" rrm beacon type refused of %d report in beacon table"),
1064 num_report );
Jeff Johnson295189b2012-06-20 16:38:30 -07001065
1066 }
1067 pReport[num_report].refused = 1;
1068 pReport[num_report].type = SIR_MAC_RRM_BEACON_TYPE;
1069 pReport[num_report].token = pRRMReq->MeasurementRequest[i].measurement_token;
1070 num_report++;
1071 continue;
1072 }
1073 else
1074 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301075 pCurrentReq = vos_mem_malloc(sizeof( *pCurrentReq ));
1076 if ( NULL == pCurrentReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 {
1078 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301079 FL( "Unable to allocate memory during RRM Req processing" ));
1080 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 return eSIR_MEM_ALLOC_FAILED;
1082 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301083 limLog( pMac, LOG3, FL(" Processing Beacon Report request") );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301084 vos_mem_set(pCurrentReq, sizeof( *pCurrentReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 pCurrentReq->dialog_token = pRRMReq->DialogToken.token;
1086 pCurrentReq->token = pRRMReq->MeasurementRequest[i].measurement_token;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +05301087 pCurrentReq->sendEmptyBcnRpt = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 pMac->rrm.rrmPEContext.pCurrentReq = pCurrentReq;
1089 rrmStatus = rrmProcessBeaconReportReq( pMac, pCurrentReq, &pRRMReq->MeasurementRequest[i], pSessionEntry );
1090 if (eRRM_SUCCESS != rrmStatus)
1091 {
1092 rrmProcessBeaconRequestFailure(pMac, pSessionEntry, peer, rrmStatus);
1093 rrmCleanup(pMac);
1094 }
1095 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301096 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 default:
1098 //Send a report with incapabale bit set.
1099 if ( pReport == NULL ) //Allocate memory to send reports for any subsequent requests.
1100 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301101 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport )
1102 * (pRRMReq->num_MeasurementRequest - i));
1103 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 {
1105 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301106 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 return eSIR_MEM_ALLOC_FAILED;
1108 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301109 vos_mem_set(pReport,
1110 sizeof( tSirMacRadioMeasureReport )
1111 * (pRRMReq->num_MeasurementRequest - i),
1112 0);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301113 limLog( pMac, LOG3,
1114 FL(" rrm beacon type incapble of %d report "),
1115 num_report );
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 }
1117 pReport[num_report].incapable = 1;
1118 pReport[num_report].type = pRRMReq->MeasurementRequest[i].measurement_type;
1119 pReport[num_report].token = pRRMReq->MeasurementRequest[i].measurement_token;
1120 num_report++;
1121 break;
1122 }
1123 }
1124
1125end:
1126 if( pReport )
1127 {
DARAM SUDHA588ae872013-12-08 07:54:56 +05301128 limSendRadioMeasureReportActionFrame( pMac, pRRMReq->DialogToken.token, num_report,
Jeff Johnson295189b2012-06-20 16:38:30 -07001129 pReport, peer, pSessionEntry );
1130
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301131 vos_mem_free(pReport);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301132 limLog( pMac, LOG3, FL(" Free memory for pReport") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 }
1134 return status;
1135
1136}
1137
1138// --------------------------------------------------------------------
1139/**
1140 * rrmUpdateStartTSF
1141 **
1142 * FUNCTION: Store start TSF of measurement.
1143 *
1144 * LOGIC:
1145 *
1146 * ASSUMPTIONS:
1147 *
1148 * NOTE:
1149 *
1150 * @param startTSF - TSF value at the start of measurement.
1151 * @return None
1152 */
1153void
1154rrmUpdateStartTSF ( tpAniSirGlobal pMac, tANI_U32 startTSF[2] )
1155{
1156#if 0 //defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001157 limLog( pMac, LOGE, "Update Start TSF = %d %d", startTSF[0], startTSF[1] );
Jeff Johnson295189b2012-06-20 16:38:30 -07001158#endif
1159 pMac->rrm.rrmPEContext.startTSF[0] = startTSF[0];
1160 pMac->rrm.rrmPEContext.startTSF[1] = startTSF[1];
1161}
1162
1163// --------------------------------------------------------------------
1164/**
1165 * rrmGetStartTSF
1166 *
1167 * FUNCTION: Get the Start TSF.
1168 *
1169 * LOGIC:
1170 *
1171 * ASSUMPTIONS:
1172 *
1173 * NOTE:
1174 *
1175 * @param startTSF - store star TSF in this buffer.
1176 * @return txPower
1177 */
1178void
1179rrmGetStartTSF ( tpAniSirGlobal pMac, tANI_U32 *pStartTSF )
1180{
1181#if 0 //defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001182 limLog( pMac, LOGE, "Get the start TSF, TSF = %d %d ", pMac->rrm.rrmPEContext.startTSF[0], pMac->rrm.rrmPEContext.startTSF[1] );
Jeff Johnson295189b2012-06-20 16:38:30 -07001183#endif
1184 pStartTSF[0] = pMac->rrm.rrmPEContext.startTSF[0];
1185 pStartTSF[1] = pMac->rrm.rrmPEContext.startTSF[1];
DARAM SUDHA588ae872013-12-08 07:54:56 +05301186
Jeff Johnson295189b2012-06-20 16:38:30 -07001187}
1188// --------------------------------------------------------------------
1189/**
1190 * rrmGetCapabilities
1191 *
1192 * FUNCTION:
1193 * Returns a pointer to tpRRMCaps with all the caps enabled in RRM
1194 *
1195 * LOGIC:
1196 *
1197 * ASSUMPTIONS:
1198 *
1199 * NOTE:
1200 *
1201 * @param pSessionEntry
1202 * @return pointer to tRRMCaps
1203 */
1204tpRRMCaps rrmGetCapabilities ( tpAniSirGlobal pMac,
1205 tpPESession pSessionEntry )
1206{
1207 return &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1208}
1209
1210// --------------------------------------------------------------------
1211/**
1212 * rrmUpdateConfig
1213 *
1214 * FUNCTION:
1215 * Update the configuration. This is called from limUpdateConfig.
1216 *
1217 * LOGIC:
1218 *
1219 * ASSUMPTIONS:
1220 *
1221 * NOTE:
1222 *
1223 * @param pSessionEntry
1224 * @return pointer to tRRMCaps
1225 */
1226void rrmUpdateConfig ( tpAniSirGlobal pMac,
1227 tpPESession pSessionEntry )
DARAM SUDHA588ae872013-12-08 07:54:56 +05301228{
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 tANI_U32 val;
1230 tpRRMCaps pRRMCaps = &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1231
1232 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
1233 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001234 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 return;
1236 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301237 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001238
1239 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_OPERATING_CHAN_MAX, &val) != eSIR_SUCCESS)
1240 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001241 limLog(pMac, LOGP, FL("cfg get rrm operating channel max measurement duration failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 return;
1243 }
1244 pRRMCaps->operatingChanMax = (tANI_U8)val;
1245
1246 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_NON_OPERATING_CHAN_MAX, &val) != eSIR_SUCCESS)
1247 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001248 limLog(pMac, LOGP, FL("cfg get rrm non-operating channel max measurement duration failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 return;
1250 }
1251 pRRMCaps->nonOperatingChanMax =(tANI_U8) val;
1252
DARAM SUDHA588ae872013-12-08 07:54:56 +05301253 limLog( pMac, LOG1,
1254 "RRM enabled = %d OperatingChanMax = %d NonOperatingMax = %d",
1255 pMac->rrm.rrmPEContext.rrmEnable,
1256 pRRMCaps->operatingChanMax, pRRMCaps->nonOperatingChanMax );
Jeff Johnson295189b2012-06-20 16:38:30 -07001257}
1258// --------------------------------------------------------------------
1259/**
1260 * rrmInitialize
1261 *
1262 * FUNCTION:
1263 * Initialize RRM module
1264 *
1265 * LOGIC:
1266 *
1267 * ASSUMPTIONS:
1268 *
1269 * NOTE:
1270 *
1271 * @return None
1272 */
1273
1274tSirRetStatus
1275rrmInitialize(tpAniSirGlobal pMac)
1276{
1277 tpRRMCaps pRRMCaps = &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1278
DARAM SUDHA588ae872013-12-08 07:54:56 +05301279 pMac->rrm.rrmPEContext.pCurrentReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 pMac->rrm.rrmPEContext.txMgmtPower = 0;
1281 pMac->rrm.rrmPEContext.DialogToken = 0;
1282
1283 pMac->rrm.rrmPEContext.rrmEnable = 0;
1284
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301285 vos_mem_set(pRRMCaps, sizeof(tRRMCaps), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 pRRMCaps->LinkMeasurement = 1;
1287 pRRMCaps->NeighborRpt = 1;
1288 pRRMCaps->BeaconPassive = 1;
1289 pRRMCaps->BeaconActive = 1;
1290 pRRMCaps->BeaconTable = 1;
1291 pRRMCaps->APChanReport = 1;
1292
1293 //pRRMCaps->TCMCapability = 1;
1294 //pRRMCaps->triggeredTCM = 1;
1295 pRRMCaps->operatingChanMax = 3;
1296 pRRMCaps->nonOperatingChanMax = 3;
1297
1298 return eSIR_SUCCESS;
1299}
1300
1301// --------------------------------------------------------------------
1302/**
1303 * rrmCleanup
1304 *
1305 * FUNCTION:
1306 * cleanup RRM module
1307 *
1308 * LOGIC:
1309 *
1310 * ASSUMPTIONS:
1311 *
1312 * NOTE:
1313 *
1314 * @param mode
1315 * @param rate
1316 * @return None
1317 */
1318
1319tSirRetStatus
1320rrmCleanup(tpAniSirGlobal pMac)
1321{
1322 if( pMac->rrm.rrmPEContext.pCurrentReq )
1323 {
1324 if( pMac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.pElementIds )
1325 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301326 vos_mem_free(pMac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.pElementIds);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301327 limLog( pMac, LOG4, FL(" Free memory for pElementIds") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 }
1329
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301330 vos_mem_free(pMac->rrm.rrmPEContext.pCurrentReq);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301331 limLog( pMac, LOG4, FL(" Free memory for pCurrentReq") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 }
1333
DARAM SUDHA588ae872013-12-08 07:54:56 +05301334 pMac->rrm.rrmPEContext.pCurrentReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 return eSIR_SUCCESS;
1336}
1337
1338// --------------------------------------------------------------------
1339/**
1340 * rrmProcessMessage
1341 *
1342 * FUNCTION: Processes the next received Radio Resource Management message
1343 *
1344 * LOGIC:
1345 *
1346 * ASSUMPTIONS:
1347 *
1348 * NOTE:
1349 *
1350 * @param None
1351 * @return None
1352 */
1353
1354void rrmProcessMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1355{
1356 switch (pMsg->type)
1357 {
1358 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
1359 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
1360 break;
1361 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
1362 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
1363 break;
1364 }
1365
1366}
1367
1368#endif