blob: c5f3f34430e7f22266488923086adcf8394e5444 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, 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 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/**=========================================================================
43
44 \file rrmApi.c
45
46 \brief implementation for PE RRM APIs
47
48 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
49
50 Qualcomm Confidential and Proprietary.
51
52 ========================================================================*/
53
54/* $Header$ */
55
56#if defined WLAN_FEATURE_VOWIFI
57
58/*--------------------------------------------------------------------------
59 Include Files
60 ------------------------------------------------------------------------*/
61#include "palTypes.h"
62#include "wniApi.h"
63#include "sirApi.h"
64#include "aniGlobal.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070065#if (WNI_POLARIS_FW_PRODUCT == AP)
66#include "wniCfgAp.h"
67#else
68#include "wniCfgSta.h"
69#endif
70#include "limTypes.h"
71#include "limUtils.h"
72#include "limSendSmeRspMessages.h"
73#include "parserApi.h"
74#include "limSendMessages.h"
75#include "rrmGlobal.h"
76#include "rrmApi.h"
77
78
79// --------------------------------------------------------------------
80/**
81 * rrmCacheMgmtTxPower
82 **
83 * FUNCTION: Store Tx power for management frames.
84 *
85 * LOGIC:
86 *
87 * ASSUMPTIONS:
88 *
89 * NOTE:
90 *
91 * @param pSessionEntry session entry.
92 * @return None
93 */
94void
95rrmCacheMgmtTxPower ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
96{
97#if defined WLAN_VOWIFI_DEBUG
98 PELOGE(limLog( pMac, LOGE, "Cache Mgmt Tx Power = %d\n", txPower );)
99#endif
100 if( pSessionEntry == NULL )
101 pMac->rrm.rrmPEContext.txMgmtPower = txPower;
102 else
103 pSessionEntry->txMgmtPower = txPower;
104}
105
106// --------------------------------------------------------------------
107/**
108 * rrmGetMgmtTxPower
109 *
110 * FUNCTION: Get the Tx power for management frames.
111 *
112 * LOGIC:
113 *
114 * ASSUMPTIONS:
115 *
116 * NOTE:
117 *
118 * @param pSessionEntry session entry.
119 * @return txPower
120 */
121tPowerdBm
122rrmGetMgmtTxPower ( tpAniSirGlobal pMac, tpPESession pSessionEntry )
123{
124#if defined WLAN_VOWIFI_DEBUG
125 PELOGE(limLog( pMac, LOGE, "RrmGetMgmtTxPower called\n" );)
126#endif
127 if( pSessionEntry == NULL )
128 return pMac->rrm.rrmPEContext.txMgmtPower;
129
130 return pSessionEntry->txMgmtPower;
131}
132
133// --------------------------------------------------------------------
134/**
135 * rrmSendSetMaxTxPowerReq
136 *
137 * FUNCTION: Send WDA_SET_MAX_TX_POWER_REQ message to change the max tx power.
138 *
139 * LOGIC:
140 *
141 * ASSUMPTIONS:
142 *
143 * NOTE:
144 *
145 * @param txPower txPower to be set.
146 * @param pSessionEntry session entry.
147 * @return None
148 */
149tSirRetStatus
150rrmSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
151{
152 tpMaxTxPowerParams pMaxTxParams;
153 tSirRetStatus retCode = eSIR_SUCCESS;
154 tSirMsgQ msgQ;
155
156 if( pSessionEntry == NULL )
157 {
158 PELOGE(limLog(pMac, LOGE, FL(" Inavalid parameters\n"));)
159 return eSIR_FAILURE;
160 }
161 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
162 (void **) &pMaxTxParams, sizeof(tMaxTxPowerParams) ) )
163 {
164 limLog( pMac, LOGP, FL("Unable to allocate memory for pMaxTxParams \n") );
165 return eSIR_MEM_ALLOC_FAILED;
166
167 }
168#if defined WLAN_VOWIFI_DEBUG
169 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pMaxTxParams...will be freed in other module\n") );)
170#endif
171 pMaxTxParams->power = txPower;
172 palCopyMemory( pMac->hHdd, pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
173 palCopyMemory( pMac->hHdd, pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
174
175
176 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
177 msgQ.reserved = 0;
178 msgQ.bodyptr = pMaxTxParams;
179 msgQ.bodyval = 0;
180
181 PELOGW(limLog(pMac, LOGW, FL( "Sending WDA_SET_MAX_TX_POWER_REQ to HAL"));)
182
Jeff Johnsone7245742012-09-05 17:12:55 -0700183 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
185 {
186 limLog( pMac, LOGP, FL("Posting WDA_SET_MAX_TX_POWER_REQ to HAL failed, reason=%X"), retCode );
187 if (NULL != pMaxTxParams)
188 {
189 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMaxTxParams );
190 }
191 return retCode;
192 }
193 return retCode;
194}
195
196
197// --------------------------------------------------------------------
198/**
199 * rrmSetMaxTxPowerRsp
200 *
201 * FUNCTION: Process WDA_SET_MAX_TX_POWER_RSP message.
202 *
203 * LOGIC:
204 *
205 * ASSUMPTIONS:
206 *
207 * NOTE:
208 *
209 * @param txPower txPower to be set.
210 * @param pSessionEntry session entry.
211 * @return None
212 */
213tSirRetStatus
214rrmSetMaxTxPowerRsp ( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
215{
216 tSirRetStatus retCode = eSIR_SUCCESS;
217 tpMaxTxPowerParams pMaxTxParams = (tpMaxTxPowerParams) limMsgQ->bodyptr;
218 tpPESession pSessionEntry;
219 tANI_U8 sessionId;
220
221 if((pSessionEntry = peFindSessionByBssid(pMac, pMaxTxParams->bssId, &sessionId))==NULL)
222 {
223 PELOGE(limLog(pMac, LOGE, FL("Unable to find session:\n") );)
224 retCode = eSIR_FAILURE;
225 }
226 else
227 {
228 rrmCacheMgmtTxPower ( pMac, pMaxTxParams->power, pSessionEntry );
229 }
230
231 palFreeMemory(pMac->hHdd, (void*)limMsgQ->bodyptr);
232 limMsgQ->bodyptr = NULL;
233 return retCode;
234}
235// --------------------------------------------------------------------
236/**
237 * rrmProcessLinkMeasurementRequest
238 *
239 * FUNCTION: Processes the Link measurement request and send the report.
240 *
241 * LOGIC:
242 *
243 * ASSUMPTIONS:
244 *
245 * NOTE:
246 *
247 * @param pBd pointer to BD to extract RSSI and SNR
248 * @param pLinkReq pointer to the Link request frame structure.
249 * @param pSessionEntry session entry.
250 * @return None
251 */
252tSirRetStatus
253rrmProcessLinkMeasurementRequest( tpAniSirGlobal pMac,
254 tANI_U8 *pRxPacketInfo,
255 tDot11fLinkMeasurementRequest *pLinkReq,
256 tpPESession pSessionEntry )
257{
258 tSirMacLinkReport LinkReport;
259 tpSirMacMgmtHdr pHdr;
260 v_S7_t currentRSSI = 0;
261
262#if defined WLAN_VOWIFI_DEBUG
263 PELOGE(limLog( pMac, LOGE, "Received Link measurement request\n");)
264#endif
265 if( pRxPacketInfo == NULL || pLinkReq == NULL || pSessionEntry == NULL )
266 {
267 PELOGE(limLog( pMac, LOGE, "%s:%d: Invalid parameters - Ignoring the request\n");)
268 return eSIR_FAILURE;
269 }
270 pHdr = WDA_GET_RX_MAC_HEADER( pRxPacketInfo );
271#if defined WLAN_VOWIFI_DEBUG
272 if( pSessionEntry->maxTxPower != (tPowerdBm) pLinkReq->MaxTxPower.maxTxPower )
273 {
274 PELOGE(limLog( pMac, LOGE, FL(" maxTx power in link request is not same as local...Local = %d LinkReq = %d\n"),
275 pSessionEntry->maxTxPower, pLinkReq->MaxTxPower.maxTxPower );)
276 }
277#endif
278
279 LinkReport.dialogToken = pLinkReq->DialogToken.token;
280 LinkReport.txPower = pSessionEntry->txMgmtPower;
281 LinkReport.rxAntenna = 0;
282 LinkReport.txAntenna = 0;
283 currentRSSI = WDA_GET_RX_RSSI_DB(pRxPacketInfo);
284
285#if defined WLAN_VOWIFI_DEBUG
286 PELOGE(limLog( pMac, LOGE, "Received Link report frame with %d\n", currentRSSI);)
287#endif
288
289 // 2008 11k spec reference: 18.4.8.5 RCPI Measurement
290 if ((currentRSSI) <= RCPI_LOW_RSSI_VALUE)
291 LinkReport.rcpi = 0;
292 else if ((currentRSSI > RCPI_LOW_RSSI_VALUE) && (currentRSSI <= 0))
293 LinkReport.rcpi = CALCULATE_RCPI(currentRSSI);
294 else
295 LinkReport.rcpi = RCPI_MAX_VALUE;
296
297 LinkReport.rsni = WDA_GET_RX_SNR(pRxPacketInfo);
298
299#if defined WLAN_VOWIFI_DEBUG
300 PELOGE(limLog( pMac, LOGE, "Sending Link report frame\n");)
301#endif
302 return limSendLinkReportActionFrame( pMac, &LinkReport, pHdr->sa, pSessionEntry );
303
304
305}
306
307// --------------------------------------------------------------------
308/**
309 * rrmProcessNeighborReportResponse
310 *
311 * FUNCTION: Processes the Neighbor Report response from the peer AP.
312 *
313 * LOGIC:
314 *
315 * ASSUMPTIONS:
316 *
317 * NOTE:
318 *
319 * @param pNeighborRep pointer to the Neighbor report frame structure.
320 * @param pSessionEntry session entry.
321 * @return None
322 */
323tSirRetStatus
324rrmProcessNeighborReportResponse( tpAniSirGlobal pMac,
325 tDot11fNeighborReportResponse *pNeighborRep,
326 tpPESession pSessionEntry )
327{
328 tSirRetStatus status = eSIR_FAILURE;
329 tpSirNeighborReportInd pSmeNeighborRpt = NULL;
330 tANI_U16 length;
331 tANI_U8 i;
332 tSirMsgQ mmhMsg;
333
334 if( pNeighborRep == NULL || pSessionEntry == NULL )
335 {
336 PELOGE(limLog( pMac, LOGE, FL(" Invalid parameters\n") );)
337 return status;
338 }
339
340#if defined WLAN_VOWIFI_DEBUG
341 PELOGE(limLog( pMac, LOGE, FL("Neighbor report response received \n") );)
342#endif
343
344 // Dialog token
345 if( pMac->rrm.rrmPEContext.DialogToken != pNeighborRep->DialogToken.token )
346 {
347 PELOGE(limLog( pMac, LOGE, "Dialog token mismatch in the received Neighbor report\n");)
348 return eSIR_FAILURE;
349 }
350 if( pNeighborRep->num_NeighborReport == 0 )
351 {
352 PELOGE(limLog( pMac, LOGE, "No neighbor report in the frame...Dropping it\n");)
353 return eSIR_FAILURE;
354 }
355 length = (sizeof( tSirNeighborReportInd )) +
356 (sizeof( tSirNeighborBssDescription ) * (pNeighborRep->num_NeighborReport - 1) ) ;
357
358 //Prepare the request to send to SME.
359 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
360 (void **) &pSmeNeighborRpt, length ) )
361 {
362 PELOGE(limLog( pMac, LOGP, FL("Unable to allocate memory\n") );)
363 return eSIR_MEM_ALLOC_FAILED;
364
365 }
366 palZeroMemory( pMac->hHdd, pSmeNeighborRpt, length );
367#if defined WLAN_VOWIFI_DEBUG
368 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pSmeNeighborRpt...will be freed by other module\n") );)
369#endif
370
371 for( i = 0 ; i < pNeighborRep->num_NeighborReport ; i++ )
372 {
373 pSmeNeighborRpt->sNeighborBssDescription[i].length = sizeof( tSirNeighborBssDescription ); /*+ any optional ies */
374 palCopyMemory( pMac->hHdd, pSmeNeighborRpt->sNeighborBssDescription[i].bssId,
375 pNeighborRep->NeighborReport[i].bssid, sizeof(tSirMacAddr) );
376 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fApPreauthReachable = pNeighborRep->NeighborReport[i].APReachability;
377 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fSameSecurityMode = pNeighborRep->NeighborReport[i].Security;
378 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fSameAuthenticator = pNeighborRep->NeighborReport[i].KeyScope;
379 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapSpectrumMeasurement = pNeighborRep->NeighborReport[i].SpecMgmtCap;
380 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapQos = pNeighborRep->NeighborReport[i].QosCap;
381 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapApsd = pNeighborRep->NeighborReport[i].apsd;
382 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapRadioMeasurement = pNeighborRep->NeighborReport[i].rrm;
383 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapDelayedBlockAck = pNeighborRep->NeighborReport[i].DelayedBA;
384 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fCapImmediateBlockAck = pNeighborRep->NeighborReport[i].ImmBA;
385 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.fMobilityDomain = pNeighborRep->NeighborReport[i].MobilityDomain;
386
387 pSmeNeighborRpt->sNeighborBssDescription[i].regClass = pNeighborRep->NeighborReport[i].regulatoryClass;
388 pSmeNeighborRpt->sNeighborBssDescription[i].channel = pNeighborRep->NeighborReport[i].channel;
389 pSmeNeighborRpt->sNeighborBssDescription[i].phyType = pNeighborRep->NeighborReport[i].PhyType;
390 }
391
392 pSmeNeighborRpt->messageType = eWNI_SME_NEIGHBOR_REPORT_IND;
393 pSmeNeighborRpt->length = length;
394 pSmeNeighborRpt->numNeighborReports = pNeighborRep->num_NeighborReport;
395 palCopyMemory( pMac->hHdd, pSmeNeighborRpt->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
396
397 //Send request to SME.
398 mmhMsg.type = pSmeNeighborRpt->messageType;
399 mmhMsg.bodyptr = pSmeNeighborRpt;
Jeff Johnsone7245742012-09-05 17:12:55 -0700400 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 status = limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
402
403 return status;
404
405}
406
407// --------------------------------------------------------------------
408/**
409 * rrmProcessNeighborReportReq
410 *
411 * FUNCTION:
412 *
413 * LOGIC: Create a Neighbor report request and send it to peer.
414 *
415 * ASSUMPTIONS:
416 *
417 * NOTE:
418 *
419 * @param pNeighborReq Neighbor report request params .
420 * @return None
421 */
422tSirRetStatus
423rrmProcessNeighborReportReq( tpAniSirGlobal pMac,
424 tpSirNeighborReportReqInd pNeighborReq )
425{
426 tSirRetStatus status = eSIR_SUCCESS;
427 tSirMacNeighborReportReq NeighborReportReq;
428 tpPESession pSessionEntry ;
429 tANI_U8 sessionId;
430
431 if( pNeighborReq == NULL )
432 {
433 PELOGE(limLog( pMac, LOGE, "NeighborReq is NULL\n" );)
434 return eSIR_FAILURE;
435 }
436 if ((pSessionEntry = peFindSessionByBssid(pMac,pNeighborReq->bssId,&sessionId))==NULL)
437 {
438 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));)
439 return eSIR_FAILURE;
440 }
441
442#if defined WLAN_VOWIFI_DEBUG
443 PELOGE(limLog( pMac, LOGE, FL("Neighbor Request received \n") );)
444 PELOGE(limLog( pMac, LOGE, "SSID present = %d \n", pNeighborReq->noSSID );)
445#endif
446
447 palZeroMemory( pMac->hHdd, &NeighborReportReq, sizeof( tSirMacNeighborReportReq ) );
448
449 NeighborReportReq.dialogToken = ++pMac->rrm.rrmPEContext.DialogToken;
450 NeighborReportReq.ssid_present = !pNeighborReq->noSSID;
451 if( NeighborReportReq.ssid_present )
452 {
453 palCopyMemory( pMac->hHdd, &NeighborReportReq.ssid, &pNeighborReq->ucSSID, sizeof(tSirMacSSid) );
454#if defined WLAN_VOWIFI_DEBUG
455 PELOGE(sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGE, (tANI_U8*) NeighborReportReq.ssid.ssId, NeighborReportReq.ssid.length );)
456#endif
457 }
458
459 status = limSendNeighborReportRequestFrame( pMac, &NeighborReportReq, pNeighborReq->bssId, pSessionEntry );
460
461 return status;
462}
463
464#define ABS(x) ((x < 0) ? -x : x)
465// --------------------------------------------------------------------
466/**
467 * rrmProcessBeaconReportReq
468 *
469 * FUNCTION: Processes the Beacon report request from the peer AP.
470 *
471 * LOGIC:
472 *
473 * ASSUMPTIONS:
474 *
475 * NOTE:
476 *
477 * @param pCurrentReq pointer to the current Req comtext.
478 * @param pBeaconReq pointer to the beacon report request IE from the peer.
479 * @param pSessionEntry session entry.
480 * @return None
481 */
482static tRrmRetStatus
483rrmProcessBeaconReportReq( tpAniSirGlobal pMac,
484 tpRRMReq pCurrentReq,
485 tDot11fIEMeasurementRequest *pBeaconReq,
486 tpPESession pSessionEntry )
487{
488 tSirMsgQ mmhMsg;
489 tpSirBeaconReportReqInd pSmeBcnReportReq;
490 tANI_U8 num_channels = 0, num_APChanReport;
491 tANI_U16 measDuration, maxMeasduration;
492 tANI_S8 maxDuration;
493 tANI_U8 sign;
494
495 if( pBeaconReq->measurement_request.Beacon.BeaconReporting.present &&
496 (pBeaconReq->measurement_request.Beacon.BeaconReporting.reportingCondition != 0) )
497 {
498 //Repeated measurement is not supported. This means number of repetitions should be zero.(Already checked)
499 //All test case in VoWifi(as of version 0.36) use zero for number of repetitions.
500 //Beacon reporting should not be included in request if number of repetitons is zero.
501 // IEEE Std 802.11k-2008 Table 7-29g and section 11.10.8.1
502
Jeff Johnson1250df42012-12-10 14:31:52 -0800503 PELOGE(limLog( pMac, LOGE, "Dropping the request: Reporting condition included in beacon report request and it is not zero\n");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 return eRRM_INCAPABLE;
505 }
506
507 /* The logic here is to check the measurement duration passed in the beacon request. Following are the cases handled.
508 Case 1: If measurement duration received in the beacon request is greater than the max measurement duration advertised
509 in the RRM capabilities(Assoc Req), and Duration Mandatory bit is set to 1, REFUSE the beacon request
510 Case 2: If measurement duration received in the beacon request is greater than the max measurement duration advertised
511 in the RRM capabilities(Assoc Req), and Duration Mandatory bit is set to 0, perform measurement for
512 the duration advertised in the RRM capabilities
513
514 maxMeasurementDuration = 2^(nonOperatingChanMax - 4) * BeaconInterval
515 */
516 maxDuration = pMac->rrm.rrmPEContext.rrmEnabledCaps.nonOperatingChanMax - 4;
517 sign = (maxDuration < 0) ? 1 : 0;
518 maxDuration = (1L << ABS(maxDuration));
519 if (!sign)
520 maxMeasduration = maxDuration * pSessionEntry->beaconParams.beaconInterval;
521 else
522 maxMeasduration = pSessionEntry->beaconParams.beaconInterval / maxDuration;
523
524 measDuration = pBeaconReq->measurement_request.Beacon.meas_duration;
525
526#if defined WLAN_VOWIFI_DEBUG
527 limLog( pMac, LOGE, "maxDuration = %d sign = %d maxMeasduration = %d measDuration = %d\n",
528 maxDuration, sign, maxMeasduration, measDuration );
529#endif
530
531 if( maxMeasduration < measDuration )
532 {
533 if( pBeaconReq->durationMandatory )
534 {
Jeff Johnson1250df42012-12-10 14:31:52 -0800535 limLog( pMac, LOGE, "Dropping the request: duration mandatory and maxduration > measduration\n");
Jeff Johnson295189b2012-06-20 16:38:30 -0700536 return eRRM_REFUSED;
537 }
538 else
539 measDuration = maxMeasduration;
540 }
541
542 //Cache the data required for sending report.
543 pCurrentReq->request.Beacon.reportingDetail = pBeaconReq->measurement_request.Beacon.BcnReportingDetail.present ?
544 pBeaconReq->measurement_request.Beacon.BcnReportingDetail.reportingDetail :
545 BEACON_REPORTING_DETAIL_ALL_FF_IE ;
546
547 if( pBeaconReq->measurement_request.Beacon.RequestedInfo.present )
548 {
549 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void**) &pCurrentReq->request.Beacon.reqIes.pElementIds,
550 ( sizeof( tANI_U8) *
551 pBeaconReq->measurement_request.Beacon.RequestedInfo.num_requested_eids ) ) )
552 {
553 limLog( pMac, LOGP,
554 FL( "Unable to PAL allocate memory for request IEs buffer\n" ));
555 return eRRM_FAILURE;
556 }
557#if defined WLAN_VOWIFI_DEBUG
558 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pElementIds\n") );)
559#endif
560 pCurrentReq->request.Beacon.reqIes.num = pBeaconReq->measurement_request.Beacon.RequestedInfo.num_requested_eids;
561 palCopyMemory ( pMac->hHdd, pCurrentReq->request.Beacon.reqIes.pElementIds,
562 pBeaconReq->measurement_request.Beacon.RequestedInfo.requested_eids,
563 pCurrentReq->request.Beacon.reqIes.num );
564 }
565
566 if( pBeaconReq->measurement_request.Beacon.num_APChannelReport )
567 {
568 for( num_APChanReport = 0 ; num_APChanReport < pBeaconReq->measurement_request.Beacon.num_APChannelReport ; num_APChanReport++ )
569 num_channels += pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList;
570 }
571
572 //Prepare the request to send to SME.
573 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
574 (void **) &pSmeBcnReportReq,
575 (sizeof( tSirBeaconReportReqInd ) + num_channels) ) )
576 {
577 limLog( pMac, LOGP,
578 FL( "Unable to PAL allocate memory during Beacon Report Req Ind to SME\n" ));
579
580 return eRRM_FAILURE;
581
582 }
583
584 palZeroMemory( pMac->hHdd, pSmeBcnReportReq, sizeof( tSirBeaconReportReqInd ) + num_channels );
585
586#if defined WLAN_VOWIFI_DEBUG
587 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pSmeBcnReportReq....will be freed by other module\n") );)
588#endif
589 palCopyMemory( pMac->hHdd, pSmeBcnReportReq->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
590 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
591 pSmeBcnReportReq->length = sizeof( tSirBeaconReportReqInd ) + num_channels;
592 pSmeBcnReportReq->uDialogToken = pBeaconReq->measurement_token;
593 //pSmeBcnReportReq->measurementDuration = SYS_TU_TO_MS(pBeaconReq->measurement_request.Beacon.meas_duration);
594 pSmeBcnReportReq->measurementDuration = SYS_TU_TO_MS(measDuration /*pBeaconReq->measurement_request.Beacon.meas_duration*/);
595 pSmeBcnReportReq->randomizationInterval = SYS_TU_TO_MS (pBeaconReq->measurement_request.Beacon.randomization);
596 pSmeBcnReportReq->fMeasurementtype = pBeaconReq->measurement_request.Beacon.meas_mode;
597 pSmeBcnReportReq->channelInfo.regulatoryClass = pBeaconReq->measurement_request.Beacon.regClass;
598 pSmeBcnReportReq->channelInfo.channelNum = pBeaconReq->measurement_request.Beacon.channel;
599 palCopyMemory( pMac->hHdd, pSmeBcnReportReq->macaddrBssid, pBeaconReq->measurement_request.Beacon.BSSID, sizeof(tSirMacAddr) );
600
601 if( pBeaconReq->measurement_request.Beacon.SSID.present )
602 {
603 pSmeBcnReportReq->ssId.length = pBeaconReq->measurement_request.Beacon.SSID.num_ssid;
604 palCopyMemory( pMac->hHdd, pSmeBcnReportReq->ssId.ssId, pBeaconReq->measurement_request.Beacon.SSID.ssid,
605 pSmeBcnReportReq->ssId.length );
606 }
607
608 pCurrentReq->token = pBeaconReq->measurement_token;
609
610 pSmeBcnReportReq->channelList.numChannels = num_channels;
611 if( pBeaconReq->measurement_request.Beacon.num_APChannelReport )
612 {
613 tANI_U8 *pChanList = pSmeBcnReportReq->channelList.channelNumber;
614 for( num_APChanReport = 0 ; num_APChanReport < pBeaconReq->measurement_request.Beacon.num_APChannelReport ; num_APChanReport++ )
615 {
616 palCopyMemory( pMac->hHdd, pChanList,
617 pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].channelList,
618 pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList );
619
620 pChanList += pBeaconReq->measurement_request.Beacon.APChannelReport[num_APChanReport].num_channelList;
621 }
622 }
623
624 //Send request to SME.
625 mmhMsg.type = eWNI_SME_BEACON_REPORT_REQ_IND;
626 mmhMsg.bodyptr = pSmeBcnReportReq;
Jeff Johnsone7245742012-09-05 17:12:55 -0700627 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 return limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
629}
630
631// --------------------------------------------------------------------
632/**
633 * rrmFillBeaconIes
634 *
635 * FUNCTION:
636 *
637 * LOGIC: Fills Fixed fields and Ies in bss description to an array of tANI_U8.
638 *
639 * ASSUMPTIONS:
640 *
641 * NOTE:
642 *
643 * @param pIes - pointer to the buffer that should be populated with ies.
644 * @param pNumIes - returns the num of ies filled in this param.
645 * @param pIesMaxSize - Max size of the buffer pIes.
646 * @param eids - pointer to array of eids. If NULL, all ies will be populated.
647 * @param numEids - number of elements in array eids.
648 * @param pBssDesc - pointer to Bss Description.
649 * @return None
650 */
651static void
652rrmFillBeaconIes( tpAniSirGlobal pMac,
653 tANI_U8 *pIes, tANI_U8 *pNumIes, tANI_U8 pIesMaxSize,
654 tANI_U8 *eids, tANI_U8 numEids,
655 tpSirBssDescription pBssDesc )
656{
657 tANI_U8 len, *pBcnIes, BcnNumIes, count = 0, i;
658
659 if( (pIes == NULL) || (pNumIes == NULL) || (pBssDesc == NULL) )
660 {
661 PELOGE(limLog( pMac, LOGE, FL(" Invalid parameters\n") );)
662 return;
663 }
664
665 //Make sure that if eid is null, numEids is set to zero.
666 numEids = (eids == NULL) ? 0 : numEids;
667
668 pBcnIes = (tANI_U8*) &pBssDesc->ieFields[0];
669 BcnNumIes = (tANI_U8)GET_IE_LEN_IN_BSS( pBssDesc->length );
670
671 *pNumIes = 0;
672
673 *((tANI_U32*)pIes) = pBssDesc->timeStamp[0];
674 *pNumIes+=sizeof(tANI_U32); pIes+=sizeof(tANI_U32);
675 *((tANI_U32*)pIes) = pBssDesc->timeStamp[1];
676 *pNumIes+=sizeof(tANI_U32); pIes+=sizeof(tANI_U32);
677 *((tANI_U16*)pIes) = pBssDesc->beaconInterval;
678 *pNumIes+=sizeof(tANI_U16); pIes+=sizeof(tANI_U16);
679 *((tANI_U16*)pIes) = pBssDesc->capabilityInfo;
680 *pNumIes+=sizeof(tANI_U16); pIes+=sizeof(tANI_U16);
681
682 while ( BcnNumIes > 0 )
683 {
684 len = *(pBcnIes + 1) + 2; //element id + length.
685#if defined WLAN_VOWIFI_DEBUG
686 PELOGE(limLog( pMac, LOGE, "EID = %d, len = %d total = %d\n", *pBcnIes, *(pBcnIes+1), len );)
687#endif
688
689 i = 0;
690 do
691 {
692 if( ( (eids == NULL) || ( *pBcnIes == eids[i] ) ) &&
693 ( (*pNumIes) + len) < pIesMaxSize )
694 {
695#if defined WLAN_VOWIFI_DEBUG
696 PELOGE(limLog( pMac, LOGE, "Adding Eid %d, len=%d\n", *pBcnIes, len );)
697#endif
698 palCopyMemory( pMac->hHdd, pIes, pBcnIes, len );
699 pIes += len;
700 *pNumIes += len;
701 count++;
702 break;
703 }
704 i++;
705 }while( i < numEids );
706
707 pBcnIes += len;
708 BcnNumIes -= len;
709 }
710#if defined WLAN_VOWIFI_DEBUG
711 PELOGE(limLog( pMac, LOGE, "Total length of Ies added = %d\n", *pNumIes );)
712#endif
713}
714
715// --------------------------------------------------------------------
716/**
717 * rrmProcessBeaconReportXmit
718 *
719 * FUNCTION:
720 *
721 * LOGIC: Create a Radio measurement report action frame and send it to peer.
722 *
723 * ASSUMPTIONS:
724 *
725 * NOTE:
726 *
727 * @param pBcnReport Data for beacon report IE from SME.
728 * @return None
729 */
730tSirRetStatus
731rrmProcessBeaconReportXmit( tpAniSirGlobal pMac,
732 tpSirBeaconReportXmitInd pBcnReport)
733{
734 tSirRetStatus status = eSIR_SUCCESS;
735 tSirMacRadioMeasureReport report, *pReport;
736 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
737 tpPESession pSessionEntry ;
738 tANI_U8 sessionId;
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530739 v_U8_t flagBSSPresent = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700740
741#if defined WLAN_VOWIFI_DEBUG
742 PELOGE(limLog( pMac, LOGE, "Received beacon report xmit indication\n");)
743#endif
744 if(NULL == pBcnReport)
745 return eSIR_FAILURE;
746
747 if ( pCurrentReq == NULL )
748 {
749 PELOGE(limLog( pMac, LOGE, "Received report xmit while there is no request pending in PE\n");)
750 return eSIR_FAILURE;
751 }
752 if ((pSessionEntry = peFindSessionByBssid(pMac,pBcnReport->bssId,&sessionId))==NULL)
753 {
754 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));)
755 return eSIR_FAILURE;
756 }
757
758 pReport = &report;
759 palZeroMemory( pMac->hHdd, pReport, sizeof(tSirMacRadioMeasureReport) );
760 //Prepare the beacon report and send it to the peer.
761 pReport->token = pBcnReport->uDialogToken;
762 pReport->refused = 0;
763 pReport->incapable = 0;
764 pReport->type = SIR_MAC_RRM_BEACON_TYPE;
765
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530766 //If the scan result is NULL then send report request with option subelement as NULL..
767 if ( NULL != pBcnReport->pBssDescription[0] )
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 {
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530769 flagBSSPresent = TRUE;
770 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700771
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530772 //Valid response is included if the size of beacon xmit is == size of beacon xmit ind + ies
773 if ( pBcnReport->length >= sizeof( tSirBeaconReportXmitInd ) )
774 {
775 pReport->report.beaconReport.regClass = pBcnReport->regClass;
776 if ( flagBSSPresent )
777 {
778 pReport->report.beaconReport.channel = pBcnReport->pBssDescription[0]->channelId;
779 palCopyMemory( pMac->hHdd, pReport->report.beaconReport.measStartTime,
780 pBcnReport->pBssDescription[0]->startTSF,
781 sizeof( pBcnReport->pBssDescription[0]->startTSF) );
782 pReport->report.beaconReport.measDuration = SYS_MS_TO_TU(pBcnReport->duration);
783 pReport->report.beaconReport.phyType = pBcnReport->pBssDescription[0]->nwType;
784 pReport->report.beaconReport.bcnProbeRsp = 1;
785 pReport->report.beaconReport.rsni = pBcnReport->pBssDescription[0]->sinr;
786 pReport->report.beaconReport.rcpi = pBcnReport->pBssDescription[0]->rssi;
787
788 pReport->report.beaconReport.antennaId = 0;
789 pReport->report.beaconReport.parentTSF = pBcnReport->pBssDescription[0]->parentTSF;
790 palCopyMemory(pMac->hHdd, pReport->report.beaconReport.bssid,
791 pBcnReport->pBssDescription[0]->bssId, sizeof(tSirMacAddr));
792 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700793
794 switch ( pCurrentReq->request.Beacon.reportingDetail )
795 {
796 case BEACON_REPORTING_DETAIL_NO_FF_IE: //0 No need to include any elements.
797#if defined WLAN_VOWIFI_DEBUG
798 PELOGE(limLog(pMac, LOGE, "No reporting detail requested\n");)
799#endif
800 break;
801 case BEACON_REPORTING_DETAIL_ALL_FF_REQ_IE: //1: Include all FFs and Requested Ies.
802#if defined WLAN_VOWIFI_DEBUG
803 PELOGE(limLog(pMac, LOGE, "Only requested IEs in reporting detail requested\n");)
804#endif
805
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530806 if ( flagBSSPresent )
807 {
808 rrmFillBeaconIes( pMac, (tANI_U8*) &pReport->report.beaconReport.Ies[0],
809 (tANI_U8*) &pReport->report.beaconReport.numIes, BEACON_REPORT_MAX_IES,
810 pCurrentReq->request.Beacon.reqIes.pElementIds, pCurrentReq->request.Beacon.reqIes.num,
811 pBcnReport->pBssDescription[0] );
812 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700813
814 break;
815 case BEACON_REPORTING_DETAIL_ALL_FF_IE: //2 / default - Include all FFs and all Ies.
816 default:
817#if defined WLAN_VOWIFI_DEBUG
818 PELOGE(limLog(pMac, LOGE, "Default all IEs and FFs\n");)
819#endif
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530820 if ( flagBSSPresent )
821 {
822 rrmFillBeaconIes( pMac, (tANI_U8*) &pReport->report.beaconReport.Ies[0],
823 (tANI_U8*) &pReport->report.beaconReport.numIes, BEACON_REPORT_MAX_IES,
824 NULL, 0,
825 pBcnReport->pBssDescription[0] );
826 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 break;
828 }
829
830#if defined WLAN_VOWIFI_DEBUG
831 PELOGE(limLog( pMac, LOGE, "Sending Action frame \n");)
832#endif
833 limSendRadioMeasureReportActionFrame( pMac, pCurrentReq->dialog_token, 1,
834 pReport, pBcnReport->bssId, pSessionEntry );
835 }
836
837 if( pBcnReport->fMeasureDone )
838 {
839 PELOGE(limLog( pMac, LOGE, "Measurement done....cleanup the context\n");)
840
841 rrmCleanup(pMac);
842 }
843 return status;
844}
845
846void rrmProcessBeaconRequestFailure(tpAniSirGlobal pMac, tpPESession pSessionEntry,
847 tSirMacAddr peer, tRrmRetStatus status)
848{
849 tpSirMacRadioMeasureReport pReport = NULL;
850 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
851
852 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
853 (void **) &pReport,
854 sizeof( tSirMacRadioMeasureReport ) ) )
855 {
856 limLog( pMac, LOGP,
857 FL( "Unable to PAL allocate memory during RRM Req processing\n" ));
858 return;
859 }
860 palZeroMemory( pMac->hHdd, pReport, sizeof(tSirMacRadioMeasureReport) );
861 pReport->token = pCurrentReq->token;
862 pReport->type = SIR_MAC_RRM_BEACON_TYPE;
863
864 switch (status)
865 {
866 case eRRM_REFUSED:
867 pReport->refused = 1;
868 break;
869 case eRRM_INCAPABLE:
870 pReport->incapable = 1;
871 break;
872 default:
873 PELOGE(limLog( pMac, LOGE, FL(" Beacon request processing failed no report sent with status %d \n"), status););
874 palFreeMemory( pMac->hHdd, pReport );
875 return;
876 }
877
878 limSendRadioMeasureReportActionFrame( pMac, pCurrentReq->dialog_token, 1,
879 pReport, peer, pSessionEntry );
880
881 palFreeMemory( pMac->hHdd, pReport );
882#if defined WLAN_VOWIFI_DEBUG
883 PELOGE(limLog( pMac, LOGE, FL(" Free memory for pReport\n") );)
884#endif
885 return;
886}
887
888// --------------------------------------------------------------------
889/**
890 * rrmProcessRadioMeasurementRequest
891 *
892 * FUNCTION: Processes the Radio Resource Measurement request.
893 *
894 * LOGIC:
895
896
897*
898 * ASSUMPTIONS:
899 *
900 * NOTE:
901 *
902 * @param peer Macaddress of the peer requesting the radio measurement.
903 * @param pRRMReq Array of Measurement request IEs
904 * @param pSessionEntry session entry.
905 * @return None
906 */
907tSirRetStatus
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530908rrmProcessRadioMeasurementRequest( tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 tSirMacAddr peer,
910 tDot11fRadioMeasurementRequest *pRRMReq,
911 tpPESession pSessionEntry )
912{
913 tANI_U8 i;
914 tSirRetStatus status = eSIR_SUCCESS;
915 tpSirMacRadioMeasureReport pReport = NULL;
916 tANI_U8 num_report = 0;
917 tpRRMReq pCurrentReq = pMac->rrm.rrmPEContext.pCurrentReq;
918 tRrmRetStatus rrmStatus = eRRM_SUCCESS;
919
920 if( !pRRMReq->num_MeasurementRequest )
921 {
922 //No measurement requests....
923 //
Gopichand Nakkala72717fd2013-02-08 12:23:45 +0530924 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
925 (void **) &pReport,
926 sizeof( tSirMacRadioMeasureReport ) ) )
927 {
928 limLog( pMac, LOGP,
929 FL( "Unable to PAL allocate memory during RRM Req processing\n" ));
930 return eSIR_MEM_ALLOC_FAILED;
931 }
932 palZeroMemory( pMac->hHdd, pReport, sizeof(tSirMacRadioMeasureReport) );
933#if defined WLAN_VOWIFI_DEBUG
934 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pReport\n") );)
935#endif
936 pReport->incapable = 1;
937 num_report = 1;
938 limSendRadioMeasureReportActionFrame( pMac, pRRMReq->DialogToken.token, num_report,
939 pReport, peer, pSessionEntry );
940 palFreeMemory( pMac->hHdd, pReport );
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 PELOGE(limLog( pMac, LOGE, "No requestIes in the measurement request\n" );)
942 return eSIR_FAILURE;
943 }
944
945 // PF Fix
946 if( pRRMReq->NumOfRepetitions.repetitions > 0 )
947 {
948 //Send a report with incapable bit set. Not supporting repetitions.
949 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
950 (void **) &pReport,
951 sizeof( tSirMacRadioMeasureReport ) ) )
952 {
953 limLog( pMac, LOGP,
954 FL( "Unable to PAL allocate memory during RRM Req processing\n" ));
955 return eSIR_MEM_ALLOC_FAILED;
956 }
957 palZeroMemory( pMac->hHdd, pReport, sizeof(tSirMacRadioMeasureReport) );
958#if defined WLAN_VOWIFI_DEBUG
959 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pReport\n") );)
960#endif
961 pReport->incapable = 1;
962 pReport->type = pRRMReq->MeasurementRequest[0].measurement_type;
963 num_report = 1;
964 goto end;
965
966 }
967
968 for( i= 0; i < pRRMReq->num_MeasurementRequest; i++ )
969 {
970 switch( pRRMReq->MeasurementRequest[i].measurement_type )
971 {
972 case SIR_MAC_RRM_BEACON_TYPE:
973 //Process beacon request.
974 if( pCurrentReq )
975 {
976 if ( pReport == NULL ) //Allocate memory to send reports for any subsequent requests.
977 {
978 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
979 (void **) &pReport,
980 sizeof( tSirMacRadioMeasureReport ) * (pRRMReq->num_MeasurementRequest - i) ) )
981 {
982 limLog( pMac, LOGP,
983 FL( "Unable to PAL allocate memory during RRM Req processing\n" ));
984 return eSIR_MEM_ALLOC_FAILED;
985 }
986 palZeroMemory( pMac->hHdd, pReport, sizeof( tSirMacRadioMeasureReport ) * (pRRMReq->num_MeasurementRequest - i) );
987#if defined WLAN_VOWIFI_DEBUG
988 limLog( pMac, LOGE, FL(" Allocated memory for pReport\n") );
989#endif
990
991 }
992 pReport[num_report].refused = 1;
993 pReport[num_report].type = SIR_MAC_RRM_BEACON_TYPE;
994 pReport[num_report].token = pRRMReq->MeasurementRequest[i].measurement_token;
995 num_report++;
996 continue;
997 }
998 else
999 {
1000 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1001 (void **) &pCurrentReq,
1002 sizeof( *pCurrentReq ) ) )
1003 {
1004 limLog( pMac, LOGP,
1005 FL( "Unable to PAL allocate memory during RRM Req processing\n" ));
1006 return eSIR_MEM_ALLOC_FAILED;
1007 }
1008#if defined WLAN_VOWIFI_DEBUG
1009 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pCurrentReq\n") );)
1010#endif
1011 palZeroMemory( pMac->hHdd, pCurrentReq, sizeof( *pCurrentReq ) );
1012 pCurrentReq->dialog_token = pRRMReq->DialogToken.token;
1013 pCurrentReq->token = pRRMReq->MeasurementRequest[i].measurement_token;
1014 pMac->rrm.rrmPEContext.pCurrentReq = pCurrentReq;
1015 rrmStatus = rrmProcessBeaconReportReq( pMac, pCurrentReq, &pRRMReq->MeasurementRequest[i], pSessionEntry );
1016 if (eRRM_SUCCESS != rrmStatus)
1017 {
1018 rrmProcessBeaconRequestFailure(pMac, pSessionEntry, peer, rrmStatus);
1019 rrmCleanup(pMac);
1020 }
1021 }
1022 break;
1023 default:
1024 //Send a report with incapabale bit set.
1025 if ( pReport == NULL ) //Allocate memory to send reports for any subsequent requests.
1026 {
1027 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1028 (void **) &pReport,
1029 sizeof( tSirMacRadioMeasureReport ) * (pRRMReq->num_MeasurementRequest - i) ) )
1030 {
1031 limLog( pMac, LOGP,
1032 FL( "Unable to PAL allocate memory during RRM Req processing\n" ));
1033 return eSIR_MEM_ALLOC_FAILED;
1034 }
1035 palZeroMemory( pMac->hHdd, pReport, sizeof( tSirMacRadioMeasureReport ) * (pRRMReq->num_MeasurementRequest - i) );
1036#if defined WLAN_VOWIFI_DEBUG
1037 PELOGE(limLog( pMac, LOGE, FL(" Allocated memory for pReport\n") );)
1038#endif
1039
1040 }
1041 pReport[num_report].incapable = 1;
1042 pReport[num_report].type = pRRMReq->MeasurementRequest[i].measurement_type;
1043 pReport[num_report].token = pRRMReq->MeasurementRequest[i].measurement_token;
1044 num_report++;
1045 break;
1046 }
1047 }
1048
1049end:
1050 if( pReport )
1051 {
1052 limSendRadioMeasureReportActionFrame( pMac, pRRMReq->DialogToken.token, num_report,
1053 pReport, peer, pSessionEntry );
1054
1055 palFreeMemory( pMac->hHdd, pReport );
1056#if defined WLAN_VOWIFI_DEBUG
1057 PELOGE(limLog( pMac, LOGE, FL(" Free memory for pReport\n") );)
1058#endif
1059 }
1060 return status;
1061
1062}
1063
1064// --------------------------------------------------------------------
1065/**
1066 * rrmUpdateStartTSF
1067 **
1068 * FUNCTION: Store start TSF of measurement.
1069 *
1070 * LOGIC:
1071 *
1072 * ASSUMPTIONS:
1073 *
1074 * NOTE:
1075 *
1076 * @param startTSF - TSF value at the start of measurement.
1077 * @return None
1078 */
1079void
1080rrmUpdateStartTSF ( tpAniSirGlobal pMac, tANI_U32 startTSF[2] )
1081{
1082#if 0 //defined WLAN_VOWIFI_DEBUG
1083 limLog( pMac, LOGE, "Update Start TSF = %d %d\n", startTSF[0], startTSF[1] );
1084#endif
1085 pMac->rrm.rrmPEContext.startTSF[0] = startTSF[0];
1086 pMac->rrm.rrmPEContext.startTSF[1] = startTSF[1];
1087}
1088
1089// --------------------------------------------------------------------
1090/**
1091 * rrmGetStartTSF
1092 *
1093 * FUNCTION: Get the Start TSF.
1094 *
1095 * LOGIC:
1096 *
1097 * ASSUMPTIONS:
1098 *
1099 * NOTE:
1100 *
1101 * @param startTSF - store star TSF in this buffer.
1102 * @return txPower
1103 */
1104void
1105rrmGetStartTSF ( tpAniSirGlobal pMac, tANI_U32 *pStartTSF )
1106{
1107#if 0 //defined WLAN_VOWIFI_DEBUG
1108 limLog( pMac, LOGE, "Get the start TSF, TSF = %d %d \n", pMac->rrm.rrmPEContext.startTSF[0], pMac->rrm.rrmPEContext.startTSF[1] );
1109#endif
1110 pStartTSF[0] = pMac->rrm.rrmPEContext.startTSF[0];
1111 pStartTSF[1] = pMac->rrm.rrmPEContext.startTSF[1];
1112
1113}
1114// --------------------------------------------------------------------
1115/**
1116 * rrmGetCapabilities
1117 *
1118 * FUNCTION:
1119 * Returns a pointer to tpRRMCaps with all the caps enabled in RRM
1120 *
1121 * LOGIC:
1122 *
1123 * ASSUMPTIONS:
1124 *
1125 * NOTE:
1126 *
1127 * @param pSessionEntry
1128 * @return pointer to tRRMCaps
1129 */
1130tpRRMCaps rrmGetCapabilities ( tpAniSirGlobal pMac,
1131 tpPESession pSessionEntry )
1132{
1133 return &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1134}
1135
1136// --------------------------------------------------------------------
1137/**
1138 * rrmUpdateConfig
1139 *
1140 * FUNCTION:
1141 * Update the configuration. This is called from limUpdateConfig.
1142 *
1143 * LOGIC:
1144 *
1145 * ASSUMPTIONS:
1146 *
1147 * NOTE:
1148 *
1149 * @param pSessionEntry
1150 * @return pointer to tRRMCaps
1151 */
1152void rrmUpdateConfig ( tpAniSirGlobal pMac,
1153 tpPESession pSessionEntry )
1154{
1155 tANI_U32 val;
1156 tpRRMCaps pRRMCaps = &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1157
1158 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
1159 {
1160 limLog(pMac, LOGP, FL("cfg get rrm enabled failed\n"));
1161 return;
1162 }
1163 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1164
1165 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_OPERATING_CHAN_MAX, &val) != eSIR_SUCCESS)
1166 {
1167 limLog(pMac, LOGP, FL("cfg get rrm operating channel max measurement duration failed\n"));
1168 return;
1169 }
1170 pRRMCaps->operatingChanMax = (tANI_U8)val;
1171
1172 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_NON_OPERATING_CHAN_MAX, &val) != eSIR_SUCCESS)
1173 {
1174 limLog(pMac, LOGP, FL("cfg get rrm non-operating channel max measurement duration failed\n"));
1175 return;
1176 }
1177 pRRMCaps->nonOperatingChanMax =(tANI_U8) val;
1178
1179#if defined WLAN_VOWIFI_DEBUG
1180 PELOGE(limLog( pMac, LOGE, "RRM enabled = %d OperatingChanMax = %d NonOperatingMax = %d\n", pMac->rrm.rrmPEContext.rrmEnable,
1181 pRRMCaps->operatingChanMax, pRRMCaps->nonOperatingChanMax );)
1182#endif
1183}
1184// --------------------------------------------------------------------
1185/**
1186 * rrmInitialize
1187 *
1188 * FUNCTION:
1189 * Initialize RRM module
1190 *
1191 * LOGIC:
1192 *
1193 * ASSUMPTIONS:
1194 *
1195 * NOTE:
1196 *
1197 * @return None
1198 */
1199
1200tSirRetStatus
1201rrmInitialize(tpAniSirGlobal pMac)
1202{
1203 tpRRMCaps pRRMCaps = &pMac->rrm.rrmPEContext.rrmEnabledCaps;
1204
1205 pMac->rrm.rrmPEContext.pCurrentReq = NULL;
1206 pMac->rrm.rrmPEContext.txMgmtPower = 0;
1207 pMac->rrm.rrmPEContext.DialogToken = 0;
1208
1209 pMac->rrm.rrmPEContext.rrmEnable = 0;
1210
1211 palZeroMemory( pMac->hHdd, pRRMCaps, sizeof(tRRMCaps) );
1212 pRRMCaps->LinkMeasurement = 1;
1213 pRRMCaps->NeighborRpt = 1;
1214 pRRMCaps->BeaconPassive = 1;
1215 pRRMCaps->BeaconActive = 1;
1216 pRRMCaps->BeaconTable = 1;
1217 pRRMCaps->APChanReport = 1;
1218
1219 //pRRMCaps->TCMCapability = 1;
1220 //pRRMCaps->triggeredTCM = 1;
1221 pRRMCaps->operatingChanMax = 3;
1222 pRRMCaps->nonOperatingChanMax = 3;
1223
1224 return eSIR_SUCCESS;
1225}
1226
1227// --------------------------------------------------------------------
1228/**
1229 * rrmCleanup
1230 *
1231 * FUNCTION:
1232 * cleanup RRM module
1233 *
1234 * LOGIC:
1235 *
1236 * ASSUMPTIONS:
1237 *
1238 * NOTE:
1239 *
1240 * @param mode
1241 * @param rate
1242 * @return None
1243 */
1244
1245tSirRetStatus
1246rrmCleanup(tpAniSirGlobal pMac)
1247{
1248 if( pMac->rrm.rrmPEContext.pCurrentReq )
1249 {
1250 if( pMac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.pElementIds )
1251 {
1252 palFreeMemory( pMac->hHdd, pMac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.pElementIds );
1253#if defined WLAN_VOWIFI_DEBUG
1254 PELOGE(limLog( pMac, LOGE, FL(" Free memory for pElementIds\n") );)
1255#endif
1256 }
1257
1258 palFreeMemory( pMac->hHdd, pMac->rrm.rrmPEContext.pCurrentReq );
1259#if defined WLAN_VOWIFI_DEBUG
1260 PELOGE(limLog( pMac, LOGE, FL(" Free memory for pCurrentReq\n") );)
1261#endif
1262 }
1263
1264 pMac->rrm.rrmPEContext.pCurrentReq = NULL;
1265 return eSIR_SUCCESS;
1266}
1267
1268// --------------------------------------------------------------------
1269/**
1270 * rrmProcessMessage
1271 *
1272 * FUNCTION: Processes the next received Radio Resource Management message
1273 *
1274 * LOGIC:
1275 *
1276 * ASSUMPTIONS:
1277 *
1278 * NOTE:
1279 *
1280 * @param None
1281 * @return None
1282 */
1283
1284void rrmProcessMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1285{
1286 switch (pMsg->type)
1287 {
1288 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
1289 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
1290 break;
1291 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
1292 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
1293 break;
1294 }
1295
1296}
1297
1298#endif