blob: 1136dc2ce00d14b1b29154b6b673fc2f8adb2033 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
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"
Jeff Johnson295189b2012-06-20 16:38:30 -070048#include "wniCfgSta.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 );
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530285 if( (uint8)(pSessionEntry->maxTxPower) != pLinkReq->MaxTxPower.maxTxPower )
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 {
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530287 PELOGW(limLog( pMac,
288 LOGW,
Madan Mohan Koyyalamudiab675df2013-07-24 02:57:41 +0530289 FL(" maxTx power in link request is not same as local... "
290 " Local = %d LinkReq = %d"),
291 pSessionEntry->maxTxPower,
292 pLinkReq->MaxTxPower.maxTxPower );)
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530293 if( (MIN_STA_PWR_CAP_DBM <= pLinkReq->MaxTxPower.maxTxPower) &&
294 (MAX_STA_PWR_CAP_DBM >= pLinkReq->MaxTxPower.maxTxPower) )
295 {
296 LinkReport.txPower = pLinkReq->MaxTxPower.maxTxPower;
297 }
298 else if( MIN_STA_PWR_CAP_DBM > pLinkReq->MaxTxPower.maxTxPower )
299 {
300 LinkReport.txPower = MIN_STA_PWR_CAP_DBM;
301 }
302 else if( MAX_STA_PWR_CAP_DBM < pLinkReq->MaxTxPower.maxTxPower )
303 {
304 LinkReport.txPower = MAX_STA_PWR_CAP_DBM;
305 }
Madan Mohan Koyyalamudiab675df2013-07-24 02:57:41 +0530306
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530307 if( (LinkReport.txPower != (uint8)(pSessionEntry->maxTxPower)) &&
Madan Mohan Koyyalamudiab675df2013-07-24 02:57:41 +0530308 (eSIR_SUCCESS == rrmSendSetMaxTxPowerReq ( pMac,
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530309 (tPowerdBm)(LinkReport.txPower),
Madan Mohan Koyyalamudiab675df2013-07-24 02:57:41 +0530310 pSessionEntry)) )
311 {
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530312 pSessionEntry->maxTxPower = (tPowerdBm)(LinkReport.txPower);
Madan Mohan Koyyalamudiab675df2013-07-24 02:57:41 +0530313 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 }
Madan Mohan Koyyalamudiba0a3f42013-08-13 20:37:34 +0530315 else
316 {
317 if( (MIN_STA_PWR_CAP_DBM <= (uint8)(pSessionEntry->maxTxPower)) &&
318 (MAX_STA_PWR_CAP_DBM >= (uint8)(pSessionEntry->maxTxPower)) )
319 {
320 LinkReport.txPower = (uint8)(pSessionEntry->maxTxPower);
321 }
322 else if( MIN_STA_PWR_CAP_DBM > (uint8)(pSessionEntry->maxTxPower) )
323 {
324 LinkReport.txPower = MIN_STA_PWR_CAP_DBM;
325 }
326 else if( MAX_STA_PWR_CAP_DBM < (uint8)(pSessionEntry->maxTxPower) )
327 {
328 LinkReport.txPower = MAX_STA_PWR_CAP_DBM;
329 }
330 }
331 PELOGW(limLog( pMac,
332 LOGW,
333 FL(" maxTx power in link request is not same as local... "
334 " Local = %d Link Report TxPower = %d"),
335 pSessionEntry->maxTxPower,
336 LinkReport.txPower );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700337
338 LinkReport.dialogToken = pLinkReq->DialogToken.token;
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 LinkReport.rxAntenna = 0;
340 LinkReport.txAntenna = 0;
341 currentRSSI = WDA_GET_RX_RSSI_DB(pRxPacketInfo);
342
DARAM SUDHA588ae872013-12-08 07:54:56 +0530343 limLog( pMac, LOG1,
344 "Received Link report frame with %d", currentRSSI);
Jeff Johnson295189b2012-06-20 16:38:30 -0700345
346 // 2008 11k spec reference: 18.4.8.5 RCPI Measurement
347 if ((currentRSSI) <= RCPI_LOW_RSSI_VALUE)
DARAM SUDHA588ae872013-12-08 07:54:56 +0530348 LinkReport.rcpi = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 else if ((currentRSSI > RCPI_LOW_RSSI_VALUE) && (currentRSSI <= 0))
350 LinkReport.rcpi = CALCULATE_RCPI(currentRSSI);
DARAM SUDHA588ae872013-12-08 07:54:56 +0530351 else
352 LinkReport.rcpi = RCPI_MAX_VALUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700353
DARAM SUDHA588ae872013-12-08 07:54:56 +0530354 LinkReport.rsni = WDA_GET_RX_SNR(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
DARAM SUDHA588ae872013-12-08 07:54:56 +0530356 limLog( pMac, LOG3, "Sending Link report frame");
Jeff Johnson295189b2012-06-20 16:38:30 -0700357
DARAM SUDHA588ae872013-12-08 07:54:56 +0530358 return limSendLinkReportActionFrame( pMac, &LinkReport, pHdr->sa, pSessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700359}
360
361// --------------------------------------------------------------------
362/**
363 * rrmProcessNeighborReportResponse
364 *
365 * FUNCTION: Processes the Neighbor Report response from the peer AP.
366 *
367 * LOGIC:
368 *
369 * ASSUMPTIONS:
370 *
371 * NOTE:
372 *
373 * @param pNeighborRep pointer to the Neighbor report frame structure.
374 * @param pSessionEntry session entry.
375 * @return None
376 */
377tSirRetStatus
378rrmProcessNeighborReportResponse( tpAniSirGlobal pMac,
379 tDot11fNeighborReportResponse *pNeighborRep,
380 tpPESession pSessionEntry )
381{
382 tSirRetStatus status = eSIR_FAILURE;
383 tpSirNeighborReportInd pSmeNeighborRpt = NULL;
384 tANI_U16 length;
385 tANI_U8 i;
386 tSirMsgQ mmhMsg;
387
388 if( pNeighborRep == NULL || pSessionEntry == NULL )
389 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700390 PELOGE(limLog( pMac, LOGE, FL(" Invalid parameters") );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 return status;
392 }
393
DARAM SUDHA588ae872013-12-08 07:54:56 +0530394 limLog( pMac, LOG3, FL("Neighbor report response received ") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700395
396 // Dialog token
397 if( pMac->rrm.rrmPEContext.DialogToken != pNeighborRep->DialogToken.token )
398 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530399 PELOGE(limLog( pMac, LOGE,
400 "Dialog token mismatch in the received Neighbor report");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 return eSIR_FAILURE;
402 }
403 if( pNeighborRep->num_NeighborReport == 0 )
404 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700405 PELOGE(limLog( pMac, LOGE, "No neighbor report in the frame...Dropping it");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 return eSIR_FAILURE;
407 }
408 length = (sizeof( tSirNeighborReportInd )) +
DARAM SUDHA588ae872013-12-08 07:54:56 +0530409 (sizeof( tSirNeighborBssDescription ) * (pNeighborRep->num_NeighborReport - 1) ) ;
410
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 //Prepare the request to send to SME.
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530412 pSmeNeighborRpt = vos_mem_malloc(length);
413 if( NULL == pSmeNeighborRpt )
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700415 PELOGE(limLog( pMac, LOGP, FL("Unable to allocate memory") );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 return eSIR_MEM_ALLOC_FAILED;
417
418 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530419 vos_mem_set(pSmeNeighborRpt, length, 0);
DARAM SUDHA588ae872013-12-08 07:54:56 +0530420
421 /* Allocated memory for pSmeNeighborRpt...will be freed by other module */
Jeff Johnson295189b2012-06-20 16:38:30 -0700422
423 for( i = 0 ; i < pNeighborRep->num_NeighborReport ; i++ )
424 {
425 pSmeNeighborRpt->sNeighborBssDescription[i].length = sizeof( tSirNeighborBssDescription ); /*+ any optional ies */
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530426 vos_mem_copy(pSmeNeighborRpt->sNeighborBssDescription[i].bssId,
427 pNeighborRep->NeighborReport[i].bssid,
428 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fApPreauthReachable = pNeighborRep->NeighborReport[i].APReachability;
430 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fSameSecurityMode = pNeighborRep->NeighborReport[i].Security;
431 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fSameAuthenticator = pNeighborRep->NeighborReport[i].KeyScope;
432 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapSpectrumMeasurement = pNeighborRep->NeighborReport[i].SpecMgmtCap;
433 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapQos = pNeighborRep->NeighborReport[i].QosCap;
434 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapApsd = pNeighborRep->NeighborReport[i].apsd;
435 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapRadioMeasurement = pNeighborRep->NeighborReport[i].rrm;
436 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapDelayedBlockAck = pNeighborRep->NeighborReport[i].DelayedBA;
437 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapImmediateBlockAck = pNeighborRep->NeighborReport[i].ImmBA;
438 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fMobilityDomain = pNeighborRep->NeighborReport[i].MobilityDomain;
439
440 pSmeNeighborRpt->sNeighborBssDescription[i].regClass = pNeighborRep->NeighborReport[i].regulatoryClass;
441 pSmeNeighborRpt->sNeighborBssDescription[i].channel = pNeighborRep->NeighborReport[i].channel;
442 pSmeNeighborRpt->sNeighborBssDescription[i].phyType = pNeighborRep->NeighborReport[i].PhyType;
443 }
444
445 pSmeNeighborRpt->messageType = eWNI_SME_NEIGHBOR_REPORT_IND;
446 pSmeNeighborRpt->length = length;
447 pSmeNeighborRpt->numNeighborReports = pNeighborRep->num_NeighborReport;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530448 vos_mem_copy(pSmeNeighborRpt->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700449
450 //Send request to SME.
451 mmhMsg.type = pSmeNeighborRpt->messageType;
452 mmhMsg.bodyptr = pSmeNeighborRpt;
Jeff Johnsone7245742012-09-05 17:12:55 -0700453 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 status = limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
455
456 return status;
457
458}
459
460// --------------------------------------------------------------------
461/**
462 * rrmProcessNeighborReportReq
463 *
DARAM SUDHA588ae872013-12-08 07:54:56 +0530464 * FUNCTION:
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 *
466 * LOGIC: Create a Neighbor report request and send it to peer.
467 *
468 * ASSUMPTIONS:
469 *
470 * NOTE:
471 *
472 * @param pNeighborReq Neighbor report request params .
473 * @return None
474 */
475tSirRetStatus
476rrmProcessNeighborReportReq( tpAniSirGlobal pMac,
477 tpSirNeighborReportReqInd pNeighborReq )
478{
479 tSirRetStatus status = eSIR_SUCCESS;
480 tSirMacNeighborReportReq NeighborReportReq;
481 tpPESession pSessionEntry ;
482 tANI_U8 sessionId;
483
484 if( pNeighborReq == NULL )
485 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700486 PELOGE(limLog( pMac, LOGE, "NeighborReq is NULL" );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 return eSIR_FAILURE;
488 }
489 if ((pSessionEntry = peFindSessionByBssid(pMac,pNeighborReq->bssId,&sessionId))==NULL)
490 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700491 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 return eSIR_FAILURE;
493 }
494
DARAM SUDHA588ae872013-12-08 07:54:56 +0530495 limLog( pMac, LOG1, FL("SSID present = %d "), pNeighborReq->noSSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700496
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530497 vos_mem_set(&NeighborReportReq,sizeof( tSirMacNeighborReportReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700499 NeighborReportReq.dialogToken = ++pMac->rrm.rrmPEContext.DialogToken;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530500 NeighborReportReq.ssid_present = !pNeighborReq->noSSID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 if( NeighborReportReq.ssid_present )
502 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530503 vos_mem_copy(&NeighborReportReq.ssid, &pNeighborReq->ucSSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 PELOGE(sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGE, (tANI_U8*) NeighborReportReq.ssid.ssId, NeighborReportReq.ssid.length );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 }
506
507 status = limSendNeighborReportRequestFrame( pMac, &NeighborReportReq, pNeighborReq->bssId, pSessionEntry );
508
509 return status;
510}
511
512#define ABS(x) ((x < 0) ? -x : x)
513// --------------------------------------------------------------------
514/**
515 * rrmProcessBeaconReportReq
516 *
517 * FUNCTION: Processes the Beacon report request from the peer AP.
518 *
519 * LOGIC:
520 *
521 * ASSUMPTIONS:
522 *
523 * NOTE:
524 *
525 * @param pCurrentReq pointer to the current Req comtext.
526 * @param pBeaconReq pointer to the beacon report request IE from the peer.
527 * @param pSessionEntry session entry.
528 * @return None
529 */
530static tRrmRetStatus
DARAM SUDHA588ae872013-12-08 07:54:56 +0530531rrmProcessBeaconReportReq( tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 tpRRMReq pCurrentReq,
533 tDot11fIEMeasurementRequest *pBeaconReq,
534 tpPESession pSessionEntry )
535{
536 tSirMsgQ mmhMsg;
537 tpSirBeaconReportReqInd pSmeBcnReportReq;
538 tANI_U8 num_channels = 0, num_APChanReport;
539 tANI_U16 measDuration, maxMeasduration;
540 tANI_S8 maxDuration;
541 tANI_U8 sign;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530542 tANI_U16 index;
Jeff Johnson295189b2012-06-20 16:38:30 -0700543
DARAM SUDHA588ae872013-12-08 07:54:56 +0530544 if( pBeaconReq->measurement_request.Beacon.BeaconReporting.present &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 (pBeaconReq->measurement_request.Beacon.BeaconReporting.reportingCondition != 0) )
546 {
547 //Repeated measurement is not supported. This means number of repetitions should be zero.(Already checked)
548 //All test case in VoWifi(as of version 0.36) use zero for number of repetitions.
549 //Beacon reporting should not be included in request if number of repetitons is zero.
550 // IEEE Std 802.11k-2008 Table 7-29g and section 11.10.8.1
551
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700552 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 -0700553 return eRRM_INCAPABLE;
554 }
555
556 /* 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 +0530557 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 -0700558 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 +0530559 Case 2: If measurement duration received in the beacon request is greater than the max measurement duration advertised
560 in the RRM capabilities(Assoc Req), and Duration Mandatory bit is set to 0, perform measurement for
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 the duration advertised in the RRM capabilities
DARAM SUDHA588ae872013-12-08 07:54:56 +0530562
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 maxMeasurementDuration = 2^(nonOperatingChanMax - 4) * BeaconInterval
564 */
565 maxDuration = pMac->rrm.rrmPEContext.rrmEnabledCaps.nonOperatingChanMax - 4;
566 sign = (maxDuration < 0) ? 1 : 0;
567 maxDuration = (1L << ABS(maxDuration));
568 if (!sign)
569 maxMeasduration = maxDuration * pSessionEntry->beaconParams.beaconInterval;
570 else
571 maxMeasduration = pSessionEntry->beaconParams.beaconInterval / maxDuration;
572
DARAM SUDHA588ae872013-12-08 07:54:56 +0530573 measDuration = pBeaconReq->measurement_request.Beacon.meas_duration;
Jeff Johnson295189b2012-06-20 16:38:30 -0700574
DARAM SUDHA588ae872013-12-08 07:54:56 +0530575 limLog( pMac, LOG3,
576 "maxDuration = %d sign = %d maxMeasduration = %d measDuration = %d",
577 maxDuration, sign, maxMeasduration, measDuration );
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
579 if( maxMeasduration < measDuration )
580 {
581 if( pBeaconReq->durationMandatory )
582 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530583 PELOGE(limLog( pMac, LOGE, "Dropping the request: duration mandatory and maxduration > measduration");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 return eRRM_REFUSED;
585 }
586 else
587 measDuration = maxMeasduration;
588 }
589
590 //Cache the data required for sending report.
591 pCurrentReq->request.Beacon.reportingDetail = pBeaconReq->measurement_request.Beacon.BcnReportingDetail.present ?
592 pBeaconReq->measurement_request.Beacon.BcnReportingDetail.reportingDetail :
593 BEACON_REPORTING_DETAIL_ALL_FF_IE ;
594
595 if( pBeaconReq->measurement_request.Beacon.RequestedInfo.present )
596 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530597 pCurrentReq->request.Beacon.reqIes.pElementIds = vos_mem_malloc(sizeof(tANI_U8) *
598 pBeaconReq->measurement_request.Beacon.RequestedInfo.num_requested_eids);
599 if ( NULL == pCurrentReq->request.Beacon.reqIes.pElementIds )
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 {
601 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530602 FL( "Unable to allocate memory for request IEs buffer" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 return eRRM_FAILURE;
604 }
DARAM SUDHA588ae872013-12-08 07:54:56 +0530605 limLog( pMac, LOG3, FL(" Allocated memory for pElementIds") );
606
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 pCurrentReq->request.Beacon.reqIes.num = pBeaconReq->measurement_request.Beacon.RequestedInfo.num_requested_eids;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530608 vos_mem_copy(pCurrentReq->request.Beacon.reqIes.pElementIds,
609 pBeaconReq->measurement_request.Beacon.RequestedInfo.requested_eids,
610 pCurrentReq->request.Beacon.reqIes.num);
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 }
612
613 if( pBeaconReq->measurement_request.Beacon.num_APChannelReport )
614 {
615 for( num_APChanReport = 0 ; num_APChanReport < pBeaconReq->measurement_request.Beacon.num_APChannelReport ; num_APChanReport++ )
616 num_channels += pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList;
617 }
618
619 //Prepare the request to send to SME.
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800620 pSmeBcnReportReq = vos_mem_malloc(sizeof( tSirBeaconReportReqInd ));
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530621 if ( NULL == pSmeBcnReportReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 {
623 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530624 FL( "Unable to allocate memory during Beacon Report Req Ind to SME" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700625
626 return eRRM_FAILURE;
627
628 }
629
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800630 vos_mem_set(pSmeBcnReportReq,sizeof( tSirBeaconReportReqInd ),0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700631
DARAM SUDHA588ae872013-12-08 07:54:56 +0530632 /* Allocated memory for pSmeBcnReportReq....will be freed by other modulea*/
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530633 vos_mem_copy(pSmeBcnReportReq->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800635 pSmeBcnReportReq->length = sizeof( tSirBeaconReportReqInd );
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 pSmeBcnReportReq->uDialogToken = pBeaconReq->measurement_token;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -0800637 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_DRV;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 pSmeBcnReportReq->randomizationInterval = SYS_TU_TO_MS (pBeaconReq->measurement_request.Beacon.randomization);
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 pSmeBcnReportReq->channelInfo.regulatoryClass = pBeaconReq->measurement_request.Beacon.regClass;
640 pSmeBcnReportReq->channelInfo.channelNum = pBeaconReq->measurement_request.Beacon.channel;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530641 vos_mem_copy(pSmeBcnReportReq->macaddrBssid, pBeaconReq->measurement_request.Beacon.BSSID,
642 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700643
644 if( pBeaconReq->measurement_request.Beacon.SSID.present )
645 {
646 pSmeBcnReportReq->ssId.length = pBeaconReq->measurement_request.Beacon.SSID.num_ssid;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530647 vos_mem_copy(pSmeBcnReportReq->ssId.ssId,
648 pBeaconReq->measurement_request.Beacon.SSID.ssid,
649 pSmeBcnReportReq->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 }
651
652 pCurrentReq->token = pBeaconReq->measurement_token;
653
654 pSmeBcnReportReq->channelList.numChannels = num_channels;
655 if( pBeaconReq->measurement_request.Beacon.num_APChannelReport )
656 {
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530657 tANI_U16 index2 = 0;
658 tANI_U8 *pChanList = pSmeBcnReportReq->channelList.channelNumber;
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 for( num_APChanReport = 0 ; num_APChanReport < pBeaconReq->measurement_request.Beacon.num_APChannelReport ; num_APChanReport++ )
660 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530661 vos_mem_copy(pChanList,
662 pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].channelList,
663 pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700664
665 pChanList += pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530666 for( index = 0; index < (pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList); index++ )
667 {
668 pSmeBcnReportReq->measurementDuration[index2] = SYS_TU_TO_MS(measDuration);
669 pSmeBcnReportReq->fMeasurementtype[index2++] = pBeaconReq->measurement_request.Beacon.meas_mode;
670 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 }
672 }
Kanchanapally, Vidyullathae7bce2c2014-01-16 12:19:26 +0530673 else
674 {
675 pSmeBcnReportReq->measurementDuration[0] = SYS_TU_TO_MS(measDuration);
676 pSmeBcnReportReq->fMeasurementtype[0] = pBeaconReq->measurement_request.Beacon.meas_mode;
677 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700678
679 //Send request to SME.
680 mmhMsg.type = eWNI_SME_BEACON_REPORT_REQ_IND;
681 mmhMsg.bodyptr = pSmeBcnReportReq;
Jeff Johnsone7245742012-09-05 17:12:55 -0700682 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 return limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
684}
685
686// --------------------------------------------------------------------
687/**
688 * rrmFillBeaconIes
689 *
DARAM SUDHA588ae872013-12-08 07:54:56 +0530690 * FUNCTION:
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 *
692 * LOGIC: Fills Fixed fields and Ies in bss description to an array of tANI_U8.
693 *
694 * ASSUMPTIONS:
695 *
696 * NOTE:
697 *
698 * @param pIes - pointer to the buffer that should be populated with ies.
699 * @param pNumIes - returns the num of ies filled in this param.
700 * @param pIesMaxSize - Max size of the buffer pIes.
701 * @param eids - pointer to array of eids. If NULL, all ies will be populated.
702 * @param numEids - number of elements in array eids.
703 * @param pBssDesc - pointer to Bss Description.
704 * @return None
705 */
706static void
DARAM SUDHA588ae872013-12-08 07:54:56 +0530707rrmFillBeaconIes( tpAniSirGlobal pMac,
708 tANI_U8 *pIes, tANI_U8 *pNumIes, tANI_U8 pIesMaxSize,
Jeff Johnson295189b2012-06-20 16:38:30 -0700709 tANI_U8 *eids, tANI_U8 numEids,
710 tpSirBssDescription pBssDesc )
711{
712 tANI_U8 len, *pBcnIes, BcnNumIes, count = 0, i;
713
714 if( (pIes == NULL) || (pNumIes == NULL) || (pBssDesc == NULL) )
715 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700716 PELOGE(limLog( pMac, LOGE, FL(" Invalid parameters") );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 return;
718 }
719
720 //Make sure that if eid is null, numEids is set to zero.
721 numEids = (eids == NULL) ? 0 : numEids;
722
723 pBcnIes = (tANI_U8*) &pBssDesc->ieFields[0];
724 BcnNumIes = (tANI_U8)GET_IE_LEN_IN_BSS( pBssDesc->length );
725
726 *pNumIes = 0;
727
728 *((tANI_U32*)pIes) = pBssDesc->timeStamp[0];
729 *pNumIes+=sizeof(tANI_U32); pIes+=sizeof(tANI_U32);
730 *((tANI_U32*)pIes) = pBssDesc->timeStamp[1];
731 *pNumIes+=sizeof(tANI_U32); pIes+=sizeof(tANI_U32);
732 *((tANI_U16*)pIes) = pBssDesc->beaconInterval;
733 *pNumIes+=sizeof(tANI_U16); pIes+=sizeof(tANI_U16);
734 *((tANI_U16*)pIes) = pBssDesc->capabilityInfo;
735 *pNumIes+=sizeof(tANI_U16); pIes+=sizeof(tANI_U16);
736
DARAM SUDHA588ae872013-12-08 07:54:56 +0530737 while ( BcnNumIes > 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 {
739 len = *(pBcnIes + 1) + 2; //element id + length.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530740 limLog( pMac, LOG3, "EID = %d, len = %d total = %d",
741 *pBcnIes, *(pBcnIes+1), len );
Jeff Johnson295189b2012-06-20 16:38:30 -0700742
743 i = 0;
744 do
DARAM SUDHA588ae872013-12-08 07:54:56 +0530745 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 if( ( (eids == NULL) || ( *pBcnIes == eids[i] ) ) &&
747 ( (*pNumIes) + len) < pIesMaxSize )
748 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530749 limLog( pMac, LOG3, "Adding Eid %d, len=%d", *pBcnIes, len );
750
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530751 vos_mem_copy(pIes, pBcnIes, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 pIes += len;
753 *pNumIes += len;
754 count++;
755 break;
756 }
757 i++;
758 }while( i < numEids );
759
760 pBcnIes += len;
761 BcnNumIes -= len;
762 }
DARAM SUDHA588ae872013-12-08 07:54:56 +0530763 limLog( pMac, LOG1, "Total length of Ies added = %d", *pNumIes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700764}
DARAM SUDHA588ae872013-12-08 07:54:56 +0530765
Jeff Johnson295189b2012-06-20 16:38:30 -0700766// --------------------------------------------------------------------
767/**
768 * rrmProcessBeaconReportXmit
769 *
DARAM SUDHA588ae872013-12-08 07:54:56 +0530770 * FUNCTION:
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 *
772 * LOGIC: Create a Radio measurement report action frame and send it to peer.
773 *
774 * ASSUMPTIONS:
775 *
776 * NOTE:
777 *
778 * @param pBcnReport Data for beacon report IE from SME.
779 * @return None
780 */
781tSirRetStatus
782rrmProcessBeaconReportXmit( tpAniSirGlobal pMac,
783 tpSirBeaconReportXmitInd pBcnReport)
784{
785 tSirRetStatus status = eSIR_SUCCESS;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530786 tSirMacRadioMeasureReport *pReport = NULL;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530787 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 tpPESession pSessionEntry ;
789 tANI_U8 sessionId;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530790 v_U8_t flagBSSPresent = FALSE, bssDescCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700791
DARAM SUDHA588ae872013-12-08 07:54:56 +0530792 limLog( pMac, LOG1, "Received beacon report xmit indication");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530793
794 if (NULL == pBcnReport)
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530796 PELOGE(limLog( pMac, LOGE,
797 "Received pBcnReport is NULL in PE");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 return eSIR_FAILURE;
799 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530800
801 if (NULL == pCurrentReq)
802 {
803 PELOGE(limLog( pMac, LOGE,
804 "Received report xmit while there is no request pending in PE");)
805 return eSIR_FAILURE;
806 }
807
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530808 if( (pBcnReport->numBssDesc) ||
809 (!pBcnReport->numBssDesc && pCurrentReq->sendEmptyBcnRpt) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 {
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530811 pBcnReport->numBssDesc = (pBcnReport->numBssDesc == RRM_BCN_RPT_NO_BSS_INFO)?
812 RRM_BCN_RPT_MIN_RPT : pBcnReport->numBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700813
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530814 if (NULL == (pSessionEntry = peFindSessionByBssid(pMac,
815 pBcnReport->bssId,
816 &sessionId)))
817 {
818 PELOGE(limLog(pMac, LOGE, FL("session does not exist for given bssId"));)
819 return eSIR_FAILURE;
820 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700821
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530822 pReport = vos_mem_malloc(pBcnReport->numBssDesc *
823 sizeof(tSirMacRadioMeasureReport));
Jeff Johnson295189b2012-06-20 16:38:30 -0700824
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530825 if (NULL == pReport)
826 {
827 PELOGE(limLog(pMac, LOGE, FL("RRM Report is NULL, allocation failed"));)
828 return eSIR_FAILURE;
829 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530830
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530831 vos_mem_zero( pReport,
832 pBcnReport->numBssDesc * sizeof(tSirMacRadioMeasureReport) );
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530833
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530834 for (bssDescCnt = 0; bssDescCnt < pBcnReport->numBssDesc; bssDescCnt++)
835 {
836 //Prepare the beacon report and send it to the peer.
837 pReport[bssDescCnt].token = pBcnReport->uDialogToken;
838 pReport[bssDescCnt].refused = 0;
839 pReport[bssDescCnt].incapable = 0;
840 pReport[bssDescCnt].type = SIR_MAC_RRM_BEACON_TYPE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700841
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530842 //If the scan result is NULL then send report request with
843 //option subelement as NULL..
844 if ( NULL != pBcnReport->pBssDescription[bssDescCnt] )
845 {
846 flagBSSPresent = TRUE;
847 }
848
849 //Valid response is included if the size of beacon xmit
850 //is == size of beacon xmit ind + ies
851 if ( pBcnReport->length >= sizeof( tSirBeaconReportXmitInd ) )
852 {
853 pReport[bssDescCnt].report.beaconReport.regClass = pBcnReport->regClass;
854 if ( flagBSSPresent )
855 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530856 pReport[bssDescCnt].report.beaconReport.channel =
857 pBcnReport->pBssDescription[bssDescCnt]->channelId;
858 vos_mem_copy( pReport[bssDescCnt].report.beaconReport.measStartTime,
859 pBcnReport->pBssDescription[bssDescCnt]->startTSF,
860 sizeof( pBcnReport->pBssDescription[bssDescCnt]->startTSF) );
861 pReport[bssDescCnt].report.beaconReport.measDuration =
862 SYS_MS_TO_TU(pBcnReport->duration);
863 pReport[bssDescCnt].report.beaconReport.phyType =
864 pBcnReport->pBssDescription[bssDescCnt]->nwType;
865 pReport[bssDescCnt].report.beaconReport.bcnProbeRsp = 1;
866 pReport[bssDescCnt].report.beaconReport.rsni =
867 pBcnReport->pBssDescription[bssDescCnt]->sinr;
868 pReport[bssDescCnt].report.beaconReport.rcpi =
869 pBcnReport->pBssDescription[bssDescCnt]->rssi;
870
871 pReport[bssDescCnt].report.beaconReport.antennaId = 0;
872 pReport[bssDescCnt].report.beaconReport.parentTSF =
873 pBcnReport->pBssDescription[bssDescCnt]->parentTSF;
874 vos_mem_copy( pReport[bssDescCnt].report.beaconReport.bssid,
875 pBcnReport->pBssDescription[bssDescCnt]->bssId,
876 sizeof(tSirMacAddr));
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530877 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530878
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530879 switch ( pCurrentReq->request.Beacon.reportingDetail )
880 {
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530881 case BEACON_REPORTING_DETAIL_NO_FF_IE:
882 //0 No need to include any elements.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530883 limLog(pMac, LOG3, "No reporting detail requested");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530884 break;
885 case BEACON_REPORTING_DETAIL_ALL_FF_REQ_IE:
886 //1: Include all FFs and Requested Ies.
DARAM SUDHA588ae872013-12-08 07:54:56 +0530887 limLog(pMac, LOG3,
888 "Only requested IEs in reporting detail requested");
Jeff Johnson295189b2012-06-20 16:38:30 -0700889
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530890 if ( flagBSSPresent )
891 {
892 rrmFillBeaconIes( pMac,
893 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.Ies[0],
894 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.numIes,
895 BEACON_REPORT_MAX_IES,
896 pCurrentReq->request.Beacon.reqIes.pElementIds,
897 pCurrentReq->request.Beacon.reqIes.num,
898 pBcnReport->pBssDescription[bssDescCnt] );
899 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700900
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530901 break;
902 case BEACON_REPORTING_DETAIL_ALL_FF_IE:
903 //2 / default - Include all FFs and all Ies.
904 default:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530905 limLog(pMac, LOG3, "Default all IEs and FFs");
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530906 if ( flagBSSPresent )
907 {
908 rrmFillBeaconIes( pMac,
909 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.Ies[0],
910 (tANI_U8*) &pReport[bssDescCnt].report.beaconReport.numIes,
911 BEACON_REPORT_MAX_IES,
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530912 NULL, 0,
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530913 pBcnReport->pBssDescription[bssDescCnt] );
914 }
915 break;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530916 }
917 }
918 }
919
920 limLog( pMac, LOG1, "Sending Action frame with %d bss info", bssDescCnt);
921 limSendRadioMeasureReportActionFrame( pMac,
922 pCurrentReq->dialog_token,
923 bssDescCnt,
924 pReport,
925 pBcnReport->bssId,
926 pSessionEntry );
927
928 pCurrentReq->sendEmptyBcnRpt = false;
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530929 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700930
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 if( pBcnReport->fMeasureDone )
932 {
DARAM SUDHA588ae872013-12-08 07:54:56 +0530933 limLog( pMac, LOG3, "Measurement done....cleanup the context");
Jeff Johnson295189b2012-06-20 16:38:30 -0700934
935 rrmCleanup(pMac);
936 }
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530937
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +0530938 if( NULL != pReport )
939 vos_mem_free(pReport);
Madan Mohan Koyyalamudic6a1d882013-09-28 22:24:21 +0530940
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 return status;
942}
943
DARAM SUDHA588ae872013-12-08 07:54:56 +0530944void rrmProcessBeaconRequestFailure(tpAniSirGlobal pMac, tpPESession pSessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 tSirMacAddr peer, tRrmRetStatus status)
946{
947 tpSirMacRadioMeasureReport pReport = NULL;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530948 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700949
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530950 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
951 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 {
953 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530954 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 return;
956 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530957 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 pReport->token = pCurrentReq->token;
959 pReport->type = SIR_MAC_RRM_BEACON_TYPE;
960
961 switch (status)
962 {
963 case eRRM_REFUSED:
964 pReport->refused = 1;
DARAM SUDHA588ae872013-12-08 07:54:56 +0530965 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700966 case eRRM_INCAPABLE:
967 pReport->incapable = 1;
968 break;
969 default:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530970 PELOGE(limLog( pMac, LOGE,
971 FL(" Beacon request processing failed no report sent with status %d "),
972 status););
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530973 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 return;
975 }
976
DARAM SUDHA588ae872013-12-08 07:54:56 +0530977 limSendRadioMeasureReportActionFrame( pMac, pCurrentReq->dialog_token, 1,
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 pReport, peer, pSessionEntry );
979
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530980 vos_mem_free(pReport);
DARAM SUDHA588ae872013-12-08 07:54:56 +0530981 limLog( pMac, LOG3, FL(" Free memory for pReport") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 return;
983}
984
985// --------------------------------------------------------------------
986/**
987 * rrmProcessRadioMeasurementRequest
988 *
989 * FUNCTION: Processes the Radio Resource Measurement request.
990 *
991 * LOGIC:
DARAM SUDHA588ae872013-12-08 07:54:56 +0530992
Jeff Johnson295189b2012-06-20 16:38:30 -0700993
994*
995 * ASSUMPTIONS:
996 *
997 * NOTE:
998 *
999 * @param peer Macaddress of the peer requesting the radio measurement.
1000 * @param pRRMReq Array of Measurement request IEs
1001 * @param pSessionEntry session entry.
1002 * @return None
1003 */
1004tSirRetStatus
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05301005rrmProcessRadioMeasurementRequest( tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 tSirMacAddr peer,
1007 tDot11fRadioMeasurementRequest *pRRMReq,
1008 tpPESession pSessionEntry )
1009{
1010 tANI_U8 i;
1011 tSirRetStatus status = eSIR_SUCCESS;
1012 tpSirMacRadioMeasureReport pReport = NULL;
1013 tANI_U8 num_report = 0;
DARAM SUDHA588ae872013-12-08 07:54:56 +05301014 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson295189b2012-06-20 16:38:30 -07001015 tRrmRetStatus rrmStatus = eRRM_SUCCESS;
1016
1017 if( !pRRMReq->num_MeasurementRequest )
1018 {
1019 //No measurement requests....
1020 //
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301021 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
1022 if ( NULL == pReport )
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05301023 {
1024 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301025 FL( "Unable to allocate memory during RRM Req processing" ));
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05301026 return eSIR_MEM_ALLOC_FAILED;
1027 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301028 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport),0);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301029 PELOGE(limLog( pMac, LOGE,
1030 FL("No requestIes in the measurement request, sending incapable report"));)
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05301031 pReport->incapable = 1;
1032 num_report = 1;
1033 limSendRadioMeasureReportActionFrame( pMac, pRRMReq->DialogToken.token, num_report,
1034 pReport, peer, pSessionEntry );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301035 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 return eSIR_FAILURE;
1037 }
1038
1039 // PF Fix
1040 if( pRRMReq->NumOfRepetitions.repetitions > 0 )
1041 {
DARAM SUDHA588ae872013-12-08 07:54:56 +05301042 limLog( pMac, LOG1,
1043 FL(" number of repetitions %d"),
1044 pRRMReq->NumOfRepetitions.repetitions );
1045
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 //Send a report with incapable bit set. Not supporting repetitions.
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301047 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport ));
1048 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 {
1050 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301051 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 return eSIR_MEM_ALLOC_FAILED;
1053 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301054 vos_mem_set(pReport, sizeof(tSirMacRadioMeasureReport), 0);
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001055 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pReport") );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 pReport->incapable = 1;
1057 pReport->type = pRRMReq->MeasurementRequest[0].measurement_type;
1058 num_report = 1;
1059 goto end;
1060
1061 }
1062
1063 for( i= 0; i < pRRMReq->num_MeasurementRequest; i++ )
1064 {
1065 switch( pRRMReq->MeasurementRequest[i].measurement_type )
1066 {
1067 case SIR_MAC_RRM_BEACON_TYPE:
1068 //Process beacon request.
1069 if( pCurrentReq )
1070 {
1071 if ( pReport == NULL ) //Allocate memory to send reports for any subsequent requests.
1072 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301073 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport )
1074 * (pRRMReq->num_MeasurementRequest - i));
1075 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 {
1077 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301078 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 return eSIR_MEM_ALLOC_FAILED;
1080 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301081 vos_mem_set(pReport,
1082 sizeof( tSirMacRadioMeasureReport )
1083 * (pRRMReq->num_MeasurementRequest - i),
1084 0);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301085 limLog( pMac, LOG3,
1086 FL(" rrm beacon type refused of %d report in beacon table"),
1087 num_report );
Jeff Johnson295189b2012-06-20 16:38:30 -07001088
1089 }
1090 pReport[num_report].refused = 1;
1091 pReport[num_report].type = SIR_MAC_RRM_BEACON_TYPE;
1092 pReport[num_report].token = pRRMReq->MeasurementRequest[i].measurement_token;
1093 num_report++;
1094 continue;
1095 }
1096 else
1097 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301098 pCurrentReq = vos_mem_malloc(sizeof( *pCurrentReq ));
1099 if ( NULL == pCurrentReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 {
1101 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301102 FL( "Unable to allocate memory during RRM Req processing" ));
1103 vos_mem_free(pReport);
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 return eSIR_MEM_ALLOC_FAILED;
1105 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301106 limLog( pMac, LOG3, FL(" Processing Beacon Report request") );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301107 vos_mem_set(pCurrentReq, sizeof( *pCurrentReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 pCurrentReq->dialog_token = pRRMReq->DialogToken.token;
1109 pCurrentReq->token = pRRMReq->MeasurementRequest[i].measurement_token;
Kanchanapally, Vidyullathaced2f422014-02-04 20:45:38 +05301110 pCurrentReq->sendEmptyBcnRpt = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 pMac->rrm.rrmPEContext.pCurrentReq = pCurrentReq;
1112 rrmStatus = rrmProcessBeaconReportReq( pMac, pCurrentReq, &pRRMReq->MeasurementRequest[i], pSessionEntry );
1113 if (eRRM_SUCCESS != rrmStatus)
1114 {
1115 rrmProcessBeaconRequestFailure(pMac, pSessionEntry, peer, rrmStatus);
1116 rrmCleanup(pMac);
1117 }
1118 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301119 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 default:
1121 //Send a report with incapabale bit set.
1122 if ( pReport == NULL ) //Allocate memory to send reports for any subsequent requests.
1123 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301124 pReport = vos_mem_malloc(sizeof( tSirMacRadioMeasureReport )
1125 * (pRRMReq->num_MeasurementRequest - i));
1126 if ( NULL == pReport )
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 {
1128 limLog( pMac, LOGP,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301129 FL( "Unable to allocate memory during RRM Req processing" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 return eSIR_MEM_ALLOC_FAILED;
1131 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301132 vos_mem_set(pReport,
1133 sizeof( tSirMacRadioMeasureReport )
1134 * (pRRMReq->num_MeasurementRequest - i),
1135 0);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301136 limLog( pMac, LOG3,
1137 FL(" rrm beacon type incapble of %d report "),
1138 num_report );
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 }
1140 pReport[num_report].incapable = 1;
1141 pReport[num_report].type = pRRMReq->MeasurementRequest[i].measurement_type;
1142 pReport[num_report].token = pRRMReq->MeasurementRequest[i].measurement_token;
1143 num_report++;
1144 break;
1145 }
1146 }
1147
1148end:
1149 if( pReport )
1150 {
DARAM SUDHA588ae872013-12-08 07:54:56 +05301151 limSendRadioMeasureReportActionFrame( pMac, pRRMReq->DialogToken.token, num_report,
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 pReport, peer, pSessionEntry );
1153
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301154 vos_mem_free(pReport);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301155 limLog( pMac, LOG3, FL(" Free memory for pReport") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001156 }
1157 return status;
1158
1159}
1160
1161// --------------------------------------------------------------------
1162/**
1163 * rrmUpdateStartTSF
1164 **
1165 * FUNCTION: Store start TSF of measurement.
1166 *
1167 * LOGIC:
1168 *
1169 * ASSUMPTIONS:
1170 *
1171 * NOTE:
1172 *
1173 * @param startTSF - TSF value at the start of measurement.
1174 * @return None
1175 */
1176void
1177rrmUpdateStartTSF ( tpAniSirGlobal pMac, tANI_U32 startTSF[2] )
1178{
1179#if 0 //defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001180 limLog( pMac, LOGE, "Update Start TSF = %d %d", startTSF[0], startTSF[1] );
Jeff Johnson295189b2012-06-20 16:38:30 -07001181#endif
1182 pMac->rrm.rrmPEContext.startTSF[0] = startTSF[0];
1183 pMac->rrm.rrmPEContext.startTSF[1] = startTSF[1];
1184}
1185
1186// --------------------------------------------------------------------
1187/**
1188 * rrmGetStartTSF
1189 *
1190 * FUNCTION: Get the Start TSF.
1191 *
1192 * LOGIC:
1193 *
1194 * ASSUMPTIONS:
1195 *
1196 * NOTE:
1197 *
1198 * @param startTSF - store star TSF in this buffer.
1199 * @return txPower
1200 */
1201void
1202rrmGetStartTSF ( tpAniSirGlobal pMac, tANI_U32 *pStartTSF )
1203{
1204#if 0 //defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001205 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 -07001206#endif
1207 pStartTSF[0] = pMac->rrm.rrmPEContext.startTSF[0];
1208 pStartTSF[1] = pMac->rrm.rrmPEContext.startTSF[1];
DARAM SUDHA588ae872013-12-08 07:54:56 +05301209
Jeff Johnson295189b2012-06-20 16:38:30 -07001210}
1211// --------------------------------------------------------------------
1212/**
1213 * rrmGetCapabilities
1214 *
1215 * FUNCTION:
1216 * Returns a pointer to tpRRMCaps with all the caps enabled in RRM
1217 *
1218 * LOGIC:
1219 *
1220 * ASSUMPTIONS:
1221 *
1222 * NOTE:
1223 *
1224 * @param pSessionEntry
1225 * @return pointer to tRRMCaps
1226 */
1227tpRRMCaps rrmGetCapabilities ( tpAniSirGlobal pMac,
1228 tpPESession pSessionEntry )
1229{
1230 return &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1231}
1232
1233// --------------------------------------------------------------------
1234/**
1235 * rrmUpdateConfig
1236 *
1237 * FUNCTION:
1238 * Update the configuration. This is called from limUpdateConfig.
1239 *
1240 * LOGIC:
1241 *
1242 * ASSUMPTIONS:
1243 *
1244 * NOTE:
1245 *
1246 * @param pSessionEntry
1247 * @return pointer to tRRMCaps
1248 */
1249void rrmUpdateConfig ( tpAniSirGlobal pMac,
1250 tpPESession pSessionEntry )
DARAM SUDHA588ae872013-12-08 07:54:56 +05301251{
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 tANI_U32 val;
1253 tpRRMCaps pRRMCaps = &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1254
1255 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
1256 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001257 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 return;
1259 }
DARAM SUDHA588ae872013-12-08 07:54:56 +05301260 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001261
1262 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_OPERATING_CHAN_MAX, &val) != eSIR_SUCCESS)
1263 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001264 limLog(pMac, LOGP, FL("cfg get rrm operating channel max measurement duration failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 return;
1266 }
1267 pRRMCaps->operatingChanMax = (tANI_U8)val;
1268
1269 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_NON_OPERATING_CHAN_MAX, &val) != eSIR_SUCCESS)
1270 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001271 limLog(pMac, LOGP, FL("cfg get rrm non-operating channel max measurement duration failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 return;
1273 }
1274 pRRMCaps->nonOperatingChanMax =(tANI_U8) val;
1275
DARAM SUDHA588ae872013-12-08 07:54:56 +05301276 limLog( pMac, LOG1,
1277 "RRM enabled = %d OperatingChanMax = %d NonOperatingMax = %d",
1278 pMac->rrm.rrmPEContext.rrmEnable,
1279 pRRMCaps->operatingChanMax, pRRMCaps->nonOperatingChanMax );
Jeff Johnson295189b2012-06-20 16:38:30 -07001280}
1281// --------------------------------------------------------------------
1282/**
1283 * rrmInitialize
1284 *
1285 * FUNCTION:
1286 * Initialize RRM module
1287 *
1288 * LOGIC:
1289 *
1290 * ASSUMPTIONS:
1291 *
1292 * NOTE:
1293 *
1294 * @return None
1295 */
1296
1297tSirRetStatus
1298rrmInitialize(tpAniSirGlobal pMac)
1299{
1300 tpRRMCaps pRRMCaps = &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1301
DARAM SUDHA588ae872013-12-08 07:54:56 +05301302 pMac->rrm.rrmPEContext.pCurrentReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 pMac->rrm.rrmPEContext.txMgmtPower = 0;
1304 pMac->rrm.rrmPEContext.DialogToken = 0;
1305
1306 pMac->rrm.rrmPEContext.rrmEnable = 0;
1307
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301308 vos_mem_set(pRRMCaps, sizeof(tRRMCaps), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001309 pRRMCaps->LinkMeasurement = 1;
1310 pRRMCaps->NeighborRpt = 1;
1311 pRRMCaps->BeaconPassive = 1;
1312 pRRMCaps->BeaconActive = 1;
1313 pRRMCaps->BeaconTable = 1;
1314 pRRMCaps->APChanReport = 1;
1315
1316 //pRRMCaps->TCMCapability = 1;
1317 //pRRMCaps->triggeredTCM = 1;
1318 pRRMCaps->operatingChanMax = 3;
1319 pRRMCaps->nonOperatingChanMax = 3;
1320
1321 return eSIR_SUCCESS;
1322}
1323
1324// --------------------------------------------------------------------
1325/**
1326 * rrmCleanup
1327 *
1328 * FUNCTION:
1329 * cleanup RRM module
1330 *
1331 * LOGIC:
1332 *
1333 * ASSUMPTIONS:
1334 *
1335 * NOTE:
1336 *
1337 * @param mode
1338 * @param rate
1339 * @return None
1340 */
1341
1342tSirRetStatus
1343rrmCleanup(tpAniSirGlobal pMac)
1344{
1345 if( pMac->rrm.rrmPEContext.pCurrentReq )
1346 {
1347 if( pMac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.pElementIds )
1348 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301349 vos_mem_free(pMac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.pElementIds);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301350 limLog( pMac, LOG4, FL(" Free memory for pElementIds") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 }
1352
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301353 vos_mem_free(pMac->rrm.rrmPEContext.pCurrentReq);
DARAM SUDHA588ae872013-12-08 07:54:56 +05301354 limLog( pMac, LOG4, FL(" Free memory for pCurrentReq") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 }
1356
DARAM SUDHA588ae872013-12-08 07:54:56 +05301357 pMac->rrm.rrmPEContext.pCurrentReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 return eSIR_SUCCESS;
1359}
1360
1361// --------------------------------------------------------------------
1362/**
1363 * rrmProcessMessage
1364 *
1365 * FUNCTION: Processes the next received Radio Resource Management message
1366 *
1367 * LOGIC:
1368 *
1369 * ASSUMPTIONS:
1370 *
1371 * NOTE:
1372 *
1373 * @param None
1374 * @return None
1375 */
1376
1377void rrmProcessMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1378{
1379 switch (pMsg->type)
1380 {
1381 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
1382 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
1383 break;
1384 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
1385 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
1386 break;
1387 }
1388
1389}
1390
1391#endif