blob: 435163546345c852cb7facb8f6a3653b91509f00 [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 );
Agrawal Ashish01c66342017-01-27 12:52:25 +0530285 LinkReport.txPower = limGetMaxTxPower (pSessionEntry->maxTxPower,
286 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 {
Kanchanapally, Vidyullatha5dbeaf22014-03-05 20:18:33 +0530625 tANI_U8 *pChanList = pSmeBcnReportReq->channelList.channelNumber;
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 for( num_APChanReport = 0 ; num_APChanReport < pBeaconReq->measurement_request.Beacon.num_APChannelReport ; num_APChanReport++ )
627 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530628 vos_mem_copy(pChanList,
629 pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].channelList,
630 pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700631
632 pChanList += pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList;
633 }
634 }
635
636 //Send request to SME.
637 mmhMsg.type = eWNI_SME_BEACON_REPORT_REQ_IND;
638 mmhMsg.bodyptr = pSmeBcnReportReq;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +0530639 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, pSessionEntry->peSessionId,
640 mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 return limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
642}
643
644// --------------------------------------------------------------------
645/**
646 * rrmFillBeaconIes
647 *
DARAM SUDHA588ae872013-12-08 07:54:56 +0530648 * FUNCTION:
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 *
650 * LOGIC: Fills Fixed fields and Ies in bss description to an array of tANI_U8.
651 *
652 * ASSUMPTIONS:
653 *
654 * NOTE:
655 *
656 * @param pIes - pointer to the buffer that should be populated with ies.
657 * @param pNumIes - returns the num of ies filled in this param.
658 * @param pIesMaxSize - Max size of the buffer pIes.
659 * @param eids - pointer to array of eids. If NULL, all ies will be populated.
660 * @param numEids - number of elements in array eids.
661 * @param pBssDesc - pointer to Bss Description.
662 * @return None
663 */
664static void
DARAM SUDHA588ae872013-12-08 07:54:56 +0530665rrmFillBeaconIes( tpAniSirGlobal pMac,
666 tANI_U8 *pIes, tANI_U8 *pNumIes, tANI_U8 pIesMaxSize,
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 tANI_U8 *eids, tANI_U8 numEids,
668 tpSirBssDescription pBssDesc )
669{
670 tANI_U8 len, *pBcnIes, BcnNumIes, count = 0, i;
671
672 if( (pIes == NULL) || (pNumIes == NULL) || (pBssDesc == NULL) )
673 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700674 PELOGE(limLog( pMac, LOGE, FL(" Invalid parameters") );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 return;
676 }
677
678 //Make sure that if eid is null, numEids is set to zero.
679 numEids = (eids == NULL) ? 0 : numEids;
680
681 pBcnIes = (tANI_U8*) &pBssDesc->ieFields[0];
682 BcnNumIes = (tANI_U8)GET_IE_LEN_IN_BSS( pBssDesc->length );
683
684 *pNumIes = 0;
685
686 *((tANI_U32*)pIes) = pBssDesc->timeStamp[0];
687 *pNumIes+=sizeof(tANI_U32); pIes+=sizeof(tANI_U32);
688 *((tANI_U32*)pIes) = pBssDesc->timeStamp[1];
689 *pNumIes+=sizeof(tANI_U32); pIes+=sizeof(tANI_U32);
690 *((tANI_U16*)pIes) = pBssDesc->beaconInterval;
691 *pNumIes+=sizeof(tANI_U16); pIes+=sizeof(tANI_U16);
692 *((tANI_U16*)pIes) = pBssDesc->capabilityInfo;
693 *pNumIes+=sizeof(tANI_U16); pIes+=sizeof(tANI_U16);
694
DARAM SUDHA588ae872013-12-08 07:54:56 +0530695 while ( BcnNumIes > 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 {
697 len = *(pBcnIes + 1) + 2; //element id + length.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530698 limLog( pMac, LOG3, "EID = %d, len = %d total = %d",
699 *pBcnIes, *(pBcnIes+1), len );
Jeff Johnson295189b2012-06-20 16:38:30 -0700700
701 i = 0;
702 do
DARAM SUDHA588ae872013-12-08 07:54:56 +0530703 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 if( ( (eids == NULL) || ( *pBcnIes == eids[i] ) ) &&
705 ( (*pNumIes) + len) < pIesMaxSize )
706 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530707 limLog( pMac, LOG3, "Adding Eid %d, len=%d", *pBcnIes, len );
708
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530709 vos_mem_copy(pIes, pBcnIes, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 pIes += len;
711 *pNumIes += len;
712 count++;
713 break;
714 }
715 i++;
716 }while( i < numEids );
717
718 pBcnIes += len;
719 BcnNumIes -= len;
720 }
DARAM SUDHA588ae872013-12-08 07:54:56 +0530721 limLog( pMac, LOG1, "Total length of Ies added = %d", *pNumIes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700722}
DARAM SUDHA588ae872013-12-08 07:54:56 +0530723
Jeff Johnson295189b2012-06-20 16:38:30 -0700724// --------------------------------------------------------------------
725/**
726 * rrmProcessBeaconReportXmit
727 *
DARAM SUDHA588ae872013-12-08 07:54:56 +0530728 * FUNCTION:
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 *
730 * LOGIC: Create a Radio measurement report action frame and send it to peer.
731 *
732 * ASSUMPTIONS:
733 *
734 * NOTE:
735 *
736 * @param pBcnReport Data for beacon report IE from SME.
737 * @return None
738 */
739tSirRetStatus
740rrmProcessBeaconReportXmit( tpAniSirGlobal pMac,
741 tpSirBeaconReportXmitInd pBcnReport)
742{
743 tSirRetStatus status = eSIR_SUCCESS;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530744 tSirMacRadioMeasureReport *pReport = NULL;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530745 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 tpPESession pSessionEntry ;
747 tANI_U8 sessionId;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530748 v_U8_t flagBSSPresent = FALSE, bssDescCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700749
DARAM SUDHA588ae872013-12-08 07:54:56 +0530750 limLog( pMac, LOG1, "Received beacon report xmit indication");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530751
752 if (NULL == pBcnReport)
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530754 PELOGE(limLog( pMac, LOGE,
755 "Received pBcnReport is NULL in PE");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 return eSIR_FAILURE;
757 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530758
759 if (NULL == pCurrentReq)
760 {
761 PELOGE(limLog( pMac, LOGE,
762 "Received report xmit while there is no request pending in PE");)
763 return eSIR_FAILURE;
764 }
765
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530766 if( (pBcnReport->numBssDesc) ||
767 (!pBcnReport->numBssDesc && pCurrentReq->sendEmptyBcnRpt) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 {
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530769 pBcnReport->numBssDesc = (pBcnReport->numBssDesc == RRM_BCN_RPT_NO_BSS_INFO)?
770 RRM_BCN_RPT_MIN_RPT : pBcnReport->numBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700771
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530772 if (NULL == (pSessionEntry = peFindSessionByBssid(pMac,
773 pBcnReport->bssId,
774 &sessionId)))
775 {
776 PELOGE(limLog(pMac, LOGE, FL("session does not exist for given bssId"));)
777 return eSIR_FAILURE;
778 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700779
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530780 pReport = vos_mem_malloc(pBcnReport->numBssDesc *
781 sizeof(tSirMacRadioMeasureReport));
Jeff Johnson295189b2012-06-20 16:38:30 -0700782
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530783 if (NULL == pReport)
784 {
785 PELOGE(limLog(pMac, LOGE, FL("RRM Report is NULL, allocation failed"));)
786 return eSIR_FAILURE;
787 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530788
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530789 vos_mem_zero( pReport,
790 pBcnReport->numBssDesc * sizeof(tSirMacRadioMeasureReport) );
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530791
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530792 for (bssDescCnt = 0; bssDescCnt < pBcnReport->numBssDesc; bssDescCnt++)
793 {
794 //Prepare the beacon report and send it to the peer.
795 pReport[bssDescCnt].token = pBcnReport->uDialogToken;
796 pReport[bssDescCnt].refused = 0;
797 pReport[bssDescCnt].incapable = 0;
798 pReport[bssDescCnt].type = SIR_MAC_RRM_BEACON_TYPE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700799
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530800 //If the scan result is NULL then send report request with
801 //option subelement as NULL..
802 if ( NULL != pBcnReport->pBssDescription[bssDescCnt] )
803 {
804 flagBSSPresent = TRUE;
805 }
806
807 //Valid response is included if the size of beacon xmit
808 //is == size of beacon xmit ind + ies
809 if ( pBcnReport->length >= sizeof( tSirBeaconReportXmitInd ) )
810 {
811 pReport[bssDescCnt].report.beaconReport.regClass = pBcnReport->regClass;
812 if ( flagBSSPresent )
813 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530814 pReport[bssDescCnt].report.beaconReport.channel =
815 pBcnReport->pBssDescription[bssDescCnt]->channelId;
816 vos_mem_copy( pReport[bssDescCnt].report.beaconReport.measStartTime,
817 pBcnReport->pBssDescription[bssDescCnt]->startTSF,
818 sizeof( pBcnReport->pBssDescription[bssDescCnt]->startTSF) );
819 pReport[bssDescCnt].report.beaconReport.measDuration =
820 SYS_MS_TO_TU(pBcnReport->duration);
821 pReport[bssDescCnt].report.beaconReport.phyType =
822 pBcnReport->pBssDescription[bssDescCnt]->nwType;
823 pReport[bssDescCnt].report.beaconReport.bcnProbeRsp = 1;
824 pReport[bssDescCnt].report.beaconReport.rsni =
825 pBcnReport->pBssDescription[bssDescCnt]->sinr;
826 pReport[bssDescCnt].report.beaconReport.rcpi =
827 pBcnReport->pBssDescription[bssDescCnt]->rssi;
828
829 pReport[bssDescCnt].report.beaconReport.antennaId = 0;
830 pReport[bssDescCnt].report.beaconReport.parentTSF =
831 pBcnReport->pBssDescription[bssDescCnt]->parentTSF;
832 vos_mem_copy( pReport[bssDescCnt].report.beaconReport.bssid,
833 pBcnReport->pBssDescription[bssDescCnt]->bssId,
834 sizeof(tSirMacAddr));
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530835 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530836
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530837 switch ( pCurrentReq->request.Beacon.reportingDetail )
838 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530839 case BEACON_REPORTING_DETAIL_NO_FF_IE:
840 //0 No need to include any elements.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530841 limLog(pMac, LOG3, "No reporting detail requested");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530842 break;
843 case BEACON_REPORTING_DETAIL_ALL_FF_REQ_IE:
844 //1: Include all FFs and Requested Ies.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530845 limLog(pMac, LOG3,
846 "Only requested IEs in reporting detail requested");
Jeff Johnson295189b2012-06-20 16:38:30 -0700847
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530848 if ( flagBSSPresent )
849 {
850 rrmFillBeaconIes( pMac,
851 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.Ies[0],
852 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.numIes,
853 BEACON_REPORT_MAX_IES,
854 pCurrentReq->request.Beacon.reqIes.pElementIds,
855 pCurrentReq->request.Beacon.reqIes.num,
856 pBcnReport->pBssDescription[bssDescCnt] );
857 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700858
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530859 break;
860 case BEACON_REPORTING_DETAIL_ALL_FF_IE:
861 //2 / default - Include all FFs and all Ies.
862 default:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530863 limLog(pMac, LOG3, "Default all IEs and FFs");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530864 if ( flagBSSPresent )
865 {
866 rrmFillBeaconIes( pMac,
867 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.Ies[0],
868 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.numIes,
869 BEACON_REPORT_MAX_IES,
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530870 NULL, 0,
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530871 pBcnReport->pBssDescription[bssDescCnt] );
872 }
873 break;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530874 }
875 }
876 }
877
878 limLog( pMac, LOG1, "Sending Action frame with %d bss info", bssDescCnt);
879 limSendRadioMeasureReportActionFrame( pMac,
880 pCurrentReq->dialog_token,
881 bssDescCnt,
882 pReport,
883 pBcnReport->bssId,
884 pSessionEntry );
885
886 pCurrentReq->sendEmptyBcnRpt = false;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530887 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700888
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 if( pBcnReport->fMeasureDone )
890 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530891 limLog( pMac, LOG3, "Measurement done....cleanup the context");
Jeff Johnson295189b2012-06-20 16:38:30 -0700892
893 rrmCleanup(pMac);
894 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530895
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530896 if( NULL != pReport )
897 vos_mem_free(pReport);
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530898
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 return status;
900}
901
DARAM SUDHA588ae872013-12-08 07:54:56 +0530902void rrmProcessBeaconRequestFailure(tpAniSirGlobal pMac, tpPESession pSessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 tSirMacAddr peer, tRrmRetStatus status)
904{
905 tpSirMacRadioMeasureReport pReport = NULL;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530906 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700907
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530908 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
909 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 {
911 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530912 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 return;
914 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530915 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 pReport->token = pCurrentReq->token;
917 pReport->type = SIR_MAC_RRM_BEACON_TYPE;
918
919 switch (status)
920 {
921 case eRRM_REFUSED:
922 pReport->refused = 1;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530923 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 case eRRM_INCAPABLE:
925 pReport->incapable = 1;
926 break;
927 default:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530928 PELOGE(limLog( pMac, LOGE,
929 FL(" Beacon request processing failed no report sent with status %d "),
930 status););
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530931 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 return;
933 }
934
DARAM SUDHA588ae872013-12-08 07:54:56 +0530935 limSendRadioMeasureReportActionFrame( pMac, pCurrentReq->dialog_token, 1,
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 pReport, peer, pSessionEntry );
937
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530938 vos_mem_free(pReport);
DARAM SUDHA588ae872013-12-08 07:54:56 +0530939 limLog( pMac, LOG3, FL(" Free memory for pReport") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 return;
941}
942
943// --------------------------------------------------------------------
944/**
945 * rrmProcessRadioMeasurementRequest
946 *
947 * FUNCTION: Processes the Radio Resource Measurement request.
948 *
949 * LOGIC:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951
952*
953 * ASSUMPTIONS:
954 *
955 * NOTE:
956 *
957 * @param peer Macaddress of the peer requesting the radio measurement.
958 * @param pRRMReq Array of Measurement request IEs
959 * @param pSessionEntry session entry.
960 * @return None
961 */
962tSirRetStatus
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530963rrmProcessRadioMeasurementRequest( tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 tSirMacAddr peer,
965 tDot11fRadioMeasurementRequest *pRRMReq,
966 tpPESession pSessionEntry )
967{
968 tANI_U8 i;
969 tSirRetStatus status = eSIR_SUCCESS;
970 tpSirMacRadioMeasureReport pReport = NULL;
971 tANI_U8 num_report = 0;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530972 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 tRrmRetStatus rrmStatus = eRRM_SUCCESS;
974
975 if( !pRRMReq->num_MeasurementRequest )
976 {
977 //No measurement requests....
978 //
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530979 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
980 if ( NULL == pReport )
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530981 {
982 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530983 FL( "Unable to allocate memory during RRM Req processing" ));
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530984 return eSIR_MEM_ALLOC_FAILED;
985 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530986 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport),0);
DARAM SUDHA588ae872013-12-08 07:54:56 +0530987 PELOGE(limLog( pMac, LOGE,
988 FL("No requestIes in the measurement request, sending incapable report"));)
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530989 pReport->incapable = 1;
990 num_report = 1;
991 limSendRadioMeasureReportActionFrame( pMac, pRRMReq->DialogToken.token, num_report,
992 pReport, peer, pSessionEntry );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530993 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 return eSIR_FAILURE;
995 }
996
997 // PF Fix
998 if( pRRMReq->NumOfRepetitions.repetitions > 0 )
999 {
DARAM SUDHA588ae872013-12-08 07:54:56 +05301000 limLog( pMac, LOG1,
1001 FL(" number of repetitions %d"),
1002 pRRMReq->NumOfRepetitions.repetitions );
1003
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 //Send a report with incapable bit set. Not supporting repetitions.
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301005 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
1006 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 {
1008 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301009 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 return eSIR_MEM_ALLOC_FAILED;
1011 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301012 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport), 0);
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001013 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pReport") );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 pReport->incapable = 1;
1015 pReport->type = pRRMReq->MeasurementRequest[0].measurement_type;
1016 num_report = 1;
1017 goto end;
1018
1019 }
1020
1021 for( i= 0; i < pRRMReq->num_MeasurementRequest; i++ )
1022 {
1023 switch( pRRMReq->MeasurementRequest[i].measurement_type )
1024 {
1025 case SIR_MAC_RRM_BEACON_TYPE:
1026 //Process beacon request.
1027 if( pCurrentReq )
1028 {
1029 if ( pReport == NULL ) //Allocate memory to send reports for any subsequent requests.
1030 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301031 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport )
1032 * (pRRMReq->num_MeasurementRequest - i));
1033 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 {
1035 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301036 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 return eSIR_MEM_ALLOC_FAILED;
1038 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301039 vos_mem_set(pReport,
1040 sizeof( tSirMacRadioMeasureReport )
1041 * (pRRMReq->num_MeasurementRequest - i),
1042 0);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301043 limLog( pMac, LOG3,
1044 FL(" rrm beacon type refused of %d report in beacon table"),
1045 num_report );
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
1047 }
1048 pReport[num_report].refused = 1;
1049 pReport[num_report].type = SIR_MAC_RRM_BEACON_TYPE;
1050 pReport[num_report].token = pRRMReq->MeasurementRequest[i].measurement_token;
1051 num_report++;
1052 continue;
1053 }
1054 else
1055 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301056 pCurrentReq = vos_mem_malloc(sizeof( *pCurrentReq ));
1057 if ( NULL == pCurrentReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 {
1059 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301060 FL( "Unable to allocate memory during RRM Req processing" ));
1061 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 return eSIR_MEM_ALLOC_FAILED;
1063 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301064 limLog( pMac, LOG3, FL(" Processing Beacon Report request") );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301065 vos_mem_set(pCurrentReq, sizeof( *pCurrentReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 pCurrentReq->dialog_token = pRRMReq->DialogToken.token;
1067 pCurrentReq->token = pRRMReq->MeasurementRequest[i].measurement_token;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +05301068 pCurrentReq->sendEmptyBcnRpt = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 pMac->rrm.rrmPEContext.pCurrentReq = pCurrentReq;
1070 rrmStatus = rrmProcessBeaconReportReq( pMac, pCurrentReq, &pRRMReq->MeasurementRequest[i], pSessionEntry );
1071 if (eRRM_SUCCESS != rrmStatus)
1072 {
1073 rrmProcessBeaconRequestFailure(pMac, pSessionEntry, peer, rrmStatus);
1074 rrmCleanup(pMac);
1075 }
1076 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 default:
1079 //Send a report with incapabale bit set.
1080 if ( pReport == NULL ) //Allocate memory to send reports for any subsequent requests.
1081 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301082 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport )
1083 * (pRRMReq->num_MeasurementRequest - i));
1084 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 {
1086 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301087 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 return eSIR_MEM_ALLOC_FAILED;
1089 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301090 vos_mem_set(pReport,
1091 sizeof( tSirMacRadioMeasureReport )
1092 * (pRRMReq->num_MeasurementRequest - i),
1093 0);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301094 limLog( pMac, LOG3,
1095 FL(" rrm beacon type incapble of %d report "),
1096 num_report );
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 }
1098 pReport[num_report].incapable = 1;
1099 pReport[num_report].type = pRRMReq->MeasurementRequest[i].measurement_type;
1100 pReport[num_report].token = pRRMReq->MeasurementRequest[i].measurement_token;
1101 num_report++;
1102 break;
1103 }
1104 }
1105
1106end:
1107 if( pReport )
1108 {
DARAM SUDHA588ae872013-12-08 07:54:56 +05301109 limSendRadioMeasureReportActionFrame( pMac, pRRMReq->DialogToken.token, num_report,
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 pReport, peer, pSessionEntry );
1111
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301112 vos_mem_free(pReport);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301113 limLog( pMac, LOG3, FL(" Free memory for pReport") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 }
1115 return status;
1116
1117}
1118
1119// --------------------------------------------------------------------
1120/**
1121 * rrmUpdateStartTSF
1122 **
1123 * FUNCTION: Store start TSF of measurement.
1124 *
1125 * LOGIC:
1126 *
1127 * ASSUMPTIONS:
1128 *
1129 * NOTE:
1130 *
1131 * @param startTSF - TSF value at the start of measurement.
1132 * @return None
1133 */
1134void
1135rrmUpdateStartTSF ( tpAniSirGlobal pMac, tANI_U32 startTSF[2] )
1136{
1137#if 0 //defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001138 limLog( pMac, LOGE, "Update Start TSF = %d %d", startTSF[0], startTSF[1] );
Jeff Johnson295189b2012-06-20 16:38:30 -07001139#endif
1140 pMac->rrm.rrmPEContext.startTSF[0] = startTSF[0];
1141 pMac->rrm.rrmPEContext.startTSF[1] = startTSF[1];
1142}
1143
1144// --------------------------------------------------------------------
1145/**
1146 * rrmGetStartTSF
1147 *
1148 * FUNCTION: Get the Start TSF.
1149 *
1150 * LOGIC:
1151 *
1152 * ASSUMPTIONS:
1153 *
1154 * NOTE:
1155 *
1156 * @param startTSF - store star TSF in this buffer.
1157 * @return txPower
1158 */
1159void
1160rrmGetStartTSF ( tpAniSirGlobal pMac, tANI_U32 *pStartTSF )
1161{
1162#if 0 //defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001163 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 -07001164#endif
1165 pStartTSF[0] = pMac->rrm.rrmPEContext.startTSF[0];
1166 pStartTSF[1] = pMac->rrm.rrmPEContext.startTSF[1];
DARAM SUDHA588ae872013-12-08 07:54:56 +05301167
Jeff Johnson295189b2012-06-20 16:38:30 -07001168}
1169// --------------------------------------------------------------------
1170/**
1171 * rrmGetCapabilities
1172 *
1173 * FUNCTION:
1174 * Returns a pointer to tpRRMCaps with all the caps enabled in RRM
1175 *
1176 * LOGIC:
1177 *
1178 * ASSUMPTIONS:
1179 *
1180 * NOTE:
1181 *
1182 * @param pSessionEntry
1183 * @return pointer to tRRMCaps
1184 */
1185tpRRMCaps rrmGetCapabilities ( tpAniSirGlobal pMac,
1186 tpPESession pSessionEntry )
1187{
1188 return &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1189}
1190
1191// --------------------------------------------------------------------
1192/**
1193 * rrmUpdateConfig
1194 *
1195 * FUNCTION:
1196 * Update the configuration. This is called from limUpdateConfig.
1197 *
1198 * LOGIC:
1199 *
1200 * ASSUMPTIONS:
1201 *
1202 * NOTE:
1203 *
1204 * @param pSessionEntry
1205 * @return pointer to tRRMCaps
1206 */
1207void rrmUpdateConfig ( tpAniSirGlobal pMac,
1208 tpPESession pSessionEntry )
DARAM SUDHA588ae872013-12-08 07:54:56 +05301209{
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 tANI_U32 val;
1211 tpRRMCaps pRRMCaps = &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1212
1213 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
1214 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001215 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001216 return;
1217 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301218 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001219
1220 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_OPERATING_CHAN_MAX, &val) != eSIR_SUCCESS)
1221 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001222 limLog(pMac, LOGP, FL("cfg get rrm operating channel max measurement duration failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 return;
1224 }
1225 pRRMCaps->operatingChanMax = (tANI_U8)val;
1226
1227 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_NON_OPERATING_CHAN_MAX, &val) != eSIR_SUCCESS)
1228 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001229 limLog(pMac, LOGP, FL("cfg get rrm non-operating channel max measurement duration failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 return;
1231 }
1232 pRRMCaps->nonOperatingChanMax =(tANI_U8) val;
1233
DARAM SUDHA588ae872013-12-08 07:54:56 +05301234 limLog( pMac, LOG1,
1235 "RRM enabled = %d OperatingChanMax = %d NonOperatingMax = %d",
1236 pMac->rrm.rrmPEContext.rrmEnable,
1237 pRRMCaps->operatingChanMax, pRRMCaps->nonOperatingChanMax );
Jeff Johnson295189b2012-06-20 16:38:30 -07001238}
1239// --------------------------------------------------------------------
1240/**
1241 * rrmInitialize
1242 *
1243 * FUNCTION:
1244 * Initialize RRM module
1245 *
1246 * LOGIC:
1247 *
1248 * ASSUMPTIONS:
1249 *
1250 * NOTE:
1251 *
1252 * @return None
1253 */
1254
1255tSirRetStatus
1256rrmInitialize(tpAniSirGlobal pMac)
1257{
1258 tpRRMCaps pRRMCaps = &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1259
DARAM SUDHA588ae872013-12-08 07:54:56 +05301260 pMac->rrm.rrmPEContext.pCurrentReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 pMac->rrm.rrmPEContext.txMgmtPower = 0;
1262 pMac->rrm.rrmPEContext.DialogToken = 0;
1263
1264 pMac->rrm.rrmPEContext.rrmEnable = 0;
1265
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301266 vos_mem_set(pRRMCaps, sizeof(tRRMCaps), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 pRRMCaps->LinkMeasurement = 1;
1268 pRRMCaps->NeighborRpt = 1;
1269 pRRMCaps->BeaconPassive = 1;
1270 pRRMCaps->BeaconActive = 1;
1271 pRRMCaps->BeaconTable = 1;
1272 pRRMCaps->APChanReport = 1;
1273
1274 //pRRMCaps->TCMCapability = 1;
1275 //pRRMCaps->triggeredTCM = 1;
1276 pRRMCaps->operatingChanMax = 3;
1277 pRRMCaps->nonOperatingChanMax = 3;
1278
1279 return eSIR_SUCCESS;
1280}
1281
1282// --------------------------------------------------------------------
1283/**
1284 * rrmCleanup
1285 *
1286 * FUNCTION:
1287 * cleanup RRM module
1288 *
1289 * LOGIC:
1290 *
1291 * ASSUMPTIONS:
1292 *
1293 * NOTE:
1294 *
1295 * @param mode
1296 * @param rate
1297 * @return None
1298 */
1299
1300tSirRetStatus
1301rrmCleanup(tpAniSirGlobal pMac)
1302{
1303 if( pMac->rrm.rrmPEContext.pCurrentReq )
1304 {
1305 if( pMac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.pElementIds )
1306 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301307 vos_mem_free(pMac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.pElementIds);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301308 limLog( pMac, LOG4, FL(" Free memory for pElementIds") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001309 }
1310
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301311 vos_mem_free(pMac->rrm.rrmPEContext.pCurrentReq);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301312 limLog( pMac, LOG4, FL(" Free memory for pCurrentReq") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 }
1314
DARAM SUDHA588ae872013-12-08 07:54:56 +05301315 pMac->rrm.rrmPEContext.pCurrentReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 return eSIR_SUCCESS;
1317}
1318
1319// --------------------------------------------------------------------
1320/**
1321 * rrmProcessMessage
1322 *
1323 * FUNCTION: Processes the next received Radio Resource Management message
1324 *
1325 * LOGIC:
1326 *
1327 * ASSUMPTIONS:
1328 *
1329 * NOTE:
1330 *
1331 * @param None
1332 * @return None
1333 */
1334
1335void rrmProcessMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1336{
1337 switch (pMsg->type)
1338 {
1339 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
1340 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
1341 break;
1342 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
1343 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
1344 break;
1345 }
1346
1347}
1348
1349#endif