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