• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * measurementMgr.c
3  *
4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  *  * Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *  * Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  *  * Neither the name Texas Instruments nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 
35 /***************************************************************************/
36 /*                                                                         */
37 /*    MODULE:   measurementMgr.c                                           */
38 /*    PURPOSE:  measurement Manager module file                            */
39 /*                                                                         */
40 /***************************************************************************/
41 
42 
43 
44 
45 #define __FILE_ID__  FILE_ID_1
46 #include "measurementMgr.h"
47 #include "regulatoryDomainApi.h"
48 #include "healthMonitor.h"
49 #include "DrvMainModules.h"
50 #include "siteMgrApi.h"
51 #include "TrafficMonitorAPI.h"
52 #include "smeApi.h"
53 #include "sme.h"
54 #ifdef XCC_MODULE_INCLUDED
55 #include "XCCTSMngr.h"
56 #endif
57 #include "TWDriver.h"
58 
59 /* default measurement parameters */
60 #define MEASUREMENT_CAPABILITIES_NONE                   0x00
61 #define MEASUREMENT_CAPABILITIES_DOT11H                 0x01
62 #define MEASUREMENT_CAPABILITIES_XCC_RM                 0x02
63 
64 
65 #define MEASUREMENT_BEACON_INTERVAL_IN_MICRO_SEC        1024
66 #define MEASUREMENT_MSEC_IN_MICRO                       1000
67 
68 
69 
70 
71 /********************************************************************************/
72 /*                      Internal functions prototypes.                          */
73 /********************************************************************************/
74 
75 static void measurementMgr_releaseModule(measurementMgr_t *pMeasurementMgr);
76 
77 static TI_BOOL measurementMgr_isTrafficIntensityHigherThanThreshold(measurementMgr_t * pMeasurementMgr);
78 
79 static TI_BOOL  measurementMgr_isRequestValid(TI_HANDLE hMeasurementMgr, MeasurementRequest_t *pRequestArr[], TI_UINT8 numOfRequest);
80 
81 static TI_BOOL measurementMgrSM_measureInProgress(TI_HANDLE hMeasurementMgr);
82 
83 
84 
85 
86 
87 /********************************************************************************/
88 /*                      Interface functions Implementation.                     */
89 /********************************************************************************/
90 
91 
92 /**
93  * Creates the Measurement Manager moodule.
94  *
95  * @param hOs A handle to the OS object.
96  *
97  * @date 16-Dec-2005
98  */
measurementMgr_create(TI_HANDLE hOs)99 TI_HANDLE measurementMgr_create(TI_HANDLE hOs)
100 {
101     measurementMgr_t * pMeasurementMgr = NULL;
102     TI_STATUS status;
103 
104     /* allocating the MeasurementMgr object */
105     pMeasurementMgr = os_memoryAlloc(hOs, sizeof(measurementMgr_t));
106 
107     if (pMeasurementMgr == NULL)
108         return NULL;
109 
110     os_memoryZero(hOs, pMeasurementMgr, sizeof(measurementMgr_t));
111     pMeasurementMgr->hOs = hOs;
112 
113     /* creating the Measurement SM */
114     status = fsm_Create(pMeasurementMgr->hOs, &(pMeasurementMgr->pMeasurementMgrSm),
115                         MEASUREMENTMGR_NUM_STATES , MEASUREMENTMGR_NUM_EVENTS);
116     if(status != TI_OK)
117     {
118         measurementMgr_releaseModule(pMeasurementMgr);
119         return NULL;
120     }
121 
122     /* creating the sub modules of measurement module */
123 
124     /* creating Request Handler sub module */
125     if( (pMeasurementMgr->hRequestH = requestHandler_create(hOs)) == NULL)
126     {
127         measurementMgr_releaseModule(pMeasurementMgr);
128         return NULL;
129     }
130 
131     return(pMeasurementMgr);
132 }
133 
134 
135 
136 
137 
138 /**
139  * Configures the Measurement Manager module.
140  *
141  * @param pStadHandles Handles to other modules the Measurement Manager needs.
142  *
143  * @date 16-Dec-2005
144  */
measurementMgr_init(TStadHandlesList * pStadHandles)145 void measurementMgr_init (TStadHandlesList *pStadHandles)
146 {
147     measurementMgr_t *pMeasurementMgr = (measurementMgr_t *)(pStadHandles->hMeasurementMgr);
148     paramInfo_t param;
149 
150     /* Init Handlers */
151     pMeasurementMgr->hRegulatoryDomain  = pStadHandles->hRegulatoryDomain;
152     pMeasurementMgr->hXCCMngr           = pStadHandles->hXCCMngr;
153     pMeasurementMgr->hSiteMgr           = pStadHandles->hSiteMgr;
154     pMeasurementMgr->hTWD               = pStadHandles->hTWD;
155     pMeasurementMgr->hMlme              = pStadHandles->hMlmeSm;
156     pMeasurementMgr->hTrafficMonitor    = pStadHandles->hTrafficMon;
157     pMeasurementMgr->hReport            = pStadHandles->hReport;
158     pMeasurementMgr->hOs                = pStadHandles->hOs;
159     pMeasurementMgr->hScr               = pStadHandles->hSCR;
160     pMeasurementMgr->hApConn            = pStadHandles->hAPConnection;
161     pMeasurementMgr->hTxCtrl            = pStadHandles->hTxCtrl;
162     pMeasurementMgr->hTimer             = pStadHandles->hTimer;
163     pMeasurementMgr->hSme               = pStadHandles->hSme;
164 
165     /* initialize variables to default values */
166     pMeasurementMgr->Enabled = TI_TRUE;
167     pMeasurementMgr->Connected = TI_FALSE;
168     pMeasurementMgr->Capabilities = MEASUREMENT_CAPABILITIES_NONE;
169     pMeasurementMgr->Mode = MSR_MODE_NONE;
170 
171     /* Getting management capability status */
172     param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
173     regulatoryDomain_getParam (pMeasurementMgr->hRegulatoryDomain, &param);
174     if (param.content.spectrumManagementEnabled)
175     {
176         pMeasurementMgr->Capabilities |= MEASUREMENT_CAPABILITIES_DOT11H;
177     }
178 
179     /* Init Functions */
180     pMeasurementMgr->parserFrameReq = NULL;
181     pMeasurementMgr->isTypeValid = NULL;
182     pMeasurementMgr->buildReport = NULL;
183     pMeasurementMgr->buildRejectReport = NULL;
184     pMeasurementMgr->sendReportAndCleanObj = NULL;
185 
186     /* initialize variables */
187     pMeasurementMgr->currentState = MEASUREMENTMGR_STATE_IDLE;
188     pMeasurementMgr->isModuleRegistered = TI_FALSE;
189     pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
190     pMeasurementMgr->measuredChannelID = 0;
191     pMeasurementMgr->currentNumOfRequestsInParallel = 0;
192     pMeasurementMgr->bMeasurementScanExecuted = TI_FALSE;
193 
194     /* config sub modules */
195     RequestHandler_config(pMeasurementMgr->hRequestH, pStadHandles->hReport, pStadHandles->hOs);
196 
197     /* Register to the SCR module */
198     scr_registerClientCB(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, measurementMgr_scrResponseCB, (TI_HANDLE)pMeasurementMgr);
199 
200     measurementMgrSM_config ((TI_HANDLE)pMeasurementMgr);
201 
202     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INIT , ": Measurement Manager configured successfully\n");
203 }
204 
205 
measurementMgr_SetDefaults(TI_HANDLE hMeasurementMgr,measurementInitParams_t * pMeasurementInitParams)206 TI_STATUS measurementMgr_SetDefaults (TI_HANDLE hMeasurementMgr, measurementInitParams_t * pMeasurementInitParams)
207 {
208     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
209 #ifdef XCC_MODULE_INCLUDED
210     TI_UINT32 currAC;
211 #endif
212 
213     pMeasurementMgr->trafficIntensityThreshold = pMeasurementInitParams->trafficIntensityThreshold;
214     pMeasurementMgr->maxDurationOnNonServingChannel = pMeasurementInitParams->maxDurationOnNonServingChannel;
215 
216     /* allocating the measurement Activation Delay timer */
217     pMeasurementMgr->hActivationDelayTimer = tmr_CreateTimer (pMeasurementMgr->hTimer);
218     if (pMeasurementMgr->hActivationDelayTimer == NULL)
219     {
220         TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, "measurementMgr_SetDefaults(): Failed to create hActivationDelayTimer!\n");
221         return TI_NOK;
222     }
223 
224 #ifdef XCC_MODULE_INCLUDED
225     /* allocating the per AC TS Metrics report timers */
226     for (currAC = 0; currAC < MAX_NUM_OF_AC; currAC++)
227     {
228         pMeasurementMgr->isTsMetricsEnabled[currAC] = TI_FALSE;
229 
230         pMeasurementMgr->hTsMetricsReportTimer[currAC] = tmr_CreateTimer (pMeasurementMgr->hTimer);
231         if (pMeasurementMgr->hTsMetricsReportTimer[currAC] == NULL)
232         {
233             TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, "measurementMgr_SetDefaults(): Failed to create hTsMetricsReportTimer!\n");
234             return TI_NOK;
235         }
236     }
237 
238     /* Check in the Registry if the station supports XCC RM */
239     if (pMeasurementInitParams->XCCEnabled == XCC_MODE_ENABLED)
240     {
241         pMeasurementMgr->Capabilities |= MEASUREMENT_CAPABILITIES_XCC_RM;
242     }
243 #endif
244 
245     return TI_OK;
246 }
247 
248 
249 
250 
251 
252 /**
253  * Sets the specified Measurement Manager parameter.
254  *
255  * @param hMeasurementMgr A handle to the Measurement Manager module.
256  * @param pParam The parameter to set.
257  *
258  * @date 16-Dec-2005
259  */
measurementMgr_setParam(TI_HANDLE hMeasurementMgr,paramInfo_t * pParam)260 TI_STATUS measurementMgr_setParam(TI_HANDLE hMeasurementMgr, paramInfo_t * pParam)
261 {
262     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
263 
264     switch (pParam->paramType)
265     {
266         case MEASUREMENT_ENABLE_DISABLE_PARAM:
267         {
268             TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MEASUREMENT_ENABLE_DISABLE_PARAM <- %d\n", pParam->content.measurementEnableDisableStatus);
269 
270             if (pParam->content.measurementEnableDisableStatus)
271             {
272                 measurementMgr_enable(pMeasurementMgr);
273             }
274             else
275             {
276                 measurementMgr_disable(pMeasurementMgr);
277             }
278 
279             break;
280         }
281 
282         case MEASUREMENT_TRAFFIC_THRESHOLD_PARAM:
283         {
284             if ((pParam->content.measurementTrafficThreshold >= MEASUREMENT_TRAFFIC_THRSHLD_MIN) &&
285                 (pParam->content.measurementTrafficThreshold <= MEASUREMENT_TRAFFIC_THRSHLD_MAX))
286             {
287                 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MEASUREMENT_TRAFFIC_THRESHOLD_PARAM <- %d\n", pParam->content.measurementTrafficThreshold);
288 
289                 pMeasurementMgr->trafficIntensityThreshold = pParam->content.measurementTrafficThreshold;
290             }
291             else
292             {
293                 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Invalid value for MEASUREMENT_TRAFFIC_THRESHOLD_PARAM (%d)\n", pParam->content.measurementTrafficThreshold);
294             }
295 
296             break;
297         }
298 
299 
300         case MEASUREMENT_MAX_DURATION_PARAM:
301         {
302             TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MEASUREMENT_MAX_DURATION_PARAM <- %d\n", pParam->content.measurementMaxDuration);
303 
304             pMeasurementMgr->maxDurationOnNonServingChannel = pParam->content.measurementMaxDuration;
305 
306             break;
307         }
308 
309 
310         default:
311         {
312             TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Specified parameter is not supported (%d)\n", pParam->paramType);
313 
314             return PARAM_NOT_SUPPORTED;
315         }
316 
317     }
318 
319     return TI_OK;
320 }
321 
322 
323 
324 
325 
326 /**
327  * Gets the specified parameter from the Measurement Manager.
328  *
329  * @param hMeasurementMgr A handle to the Measurement Manager module.
330  * @param pParam The parameter to get.
331  *
332  * @date 16-Dec-2005
333  */
measurementMgr_getParam(TI_HANDLE hMeasurementMgr,paramInfo_t * pParam)334 TI_STATUS measurementMgr_getParam(TI_HANDLE hMeasurementMgr, paramInfo_t * pParam)
335 {
336     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
337 
338     switch(pParam->paramType)
339     {
340 
341         case MEASUREMENT_GET_STATUS_PARAM:
342         {
343             WLAN_OS_REPORT(("%s: \n\n", __FUNCTION__));
344             WLAN_OS_REPORT(("MeasurementMgr Status Report:\n\n"));
345 
346             WLAN_OS_REPORT(("Current State: %d\n\n", pMeasurementMgr->currentState));
347 
348             WLAN_OS_REPORT(("Connected: %d\n", pMeasurementMgr->Connected));
349             WLAN_OS_REPORT(("Enabled: %d\n\n", pMeasurementMgr->Enabled));
350 
351             WLAN_OS_REPORT(("Mode: %d\n", pMeasurementMgr->Mode));
352             WLAN_OS_REPORT(("Capabilities: %d\n\n", pMeasurementMgr->Capabilities));
353 
354             WLAN_OS_REPORT(("current Frame Type: %d\n", pMeasurementMgr->currentFrameType));
355             WLAN_OS_REPORT(("Measured Channel: %d\n", pMeasurementMgr->measuredChannelID));
356             WLAN_OS_REPORT(("Serving Channel: %d\n", pMeasurementMgr->servingChannelID));
357             WLAN_OS_REPORT(("Traffic Intensity Threshold: %d\n", pMeasurementMgr->trafficIntensityThreshold));
358             WLAN_OS_REPORT(("Max Duration on Nonserving Channel: %d\n", pMeasurementMgr->maxDurationOnNonServingChannel));
359 
360             break;
361         }
362 
363 
364         default:
365         {
366             TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Specified parameter is not supported (%d)\n", pParam->paramType);
367 
368             return PARAM_NOT_SUPPORTED;
369         }
370 
371     }
372 
373     return TI_OK;
374 }
375 
376 
377 
378 
379 
380 
381 /**
382  * Signals the Measurement Manager that the STA is connected.
383  *
384  * @param hMeasurementMgr A handle to the Measurement Manager module.
385  *
386  * @date 16-Dec-2005
387  */
measurementMgr_connected(TI_HANDLE hMeasurementMgr)388 TI_STATUS measurementMgr_connected(TI_HANDLE hMeasurementMgr)
389 {
390     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
391 
392     /* checking if measurement is enabled */
393     if (pMeasurementMgr->Mode == MSR_MODE_NONE)
394         return TI_OK;
395 
396     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr set to connected.\n");
397 
398     return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
399                                MEASUREMENTMGR_EVENT_CONNECTED, pMeasurementMgr);
400 }
401 
402 
403 
404 
405 
406 /**
407  * Signals the Measurement Manager that the STA is disconnected.
408  *
409  * @param hMeasurementMgr A handle to the Measurement Manager module.
410  *
411  * @date 16-Dec-2005
412  */
measurementMgr_disconnected(TI_HANDLE hMeasurementMgr)413 TI_STATUS measurementMgr_disconnected(TI_HANDLE hMeasurementMgr)
414 {
415     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
416 
417     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr set to disconnected.\n");
418 
419     return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
420                                 MEASUREMENTMGR_EVENT_DISCONNECTED, pMeasurementMgr);
421 }
422 
423 
424 
425 
426 /**
427  * Enables the Measurement Manager module.
428  *
429  * @date 10-Jan-2006
430  */
measurementMgr_enable(TI_HANDLE hMeasurementMgr)431 TI_STATUS measurementMgr_enable(TI_HANDLE hMeasurementMgr)
432 {
433     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
434 
435     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr set to enabled.\n");
436 
437     return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
438                                 MEASUREMENTMGR_EVENT_ENABLE, pMeasurementMgr);
439 }
440 
441 
442 
443 
444 
445 /**
446  * Disables the Measurement Manager module.
447  *
448  * @date 10-Jan-2006
449  */
measurementMgr_disable(TI_HANDLE hMeasurementMgr)450 TI_STATUS measurementMgr_disable(TI_HANDLE hMeasurementMgr)
451 {
452     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
453 
454     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr set to disabled.\n");
455 
456     return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
457                                 MEASUREMENTMGR_EVENT_DISABLE, pMeasurementMgr);
458 }
459 
460 
461 
462 
463 
464 /**
465  * Destroys the Measurement Manager module.
466  *
467  * @param hMeasurementMgr A handle to the Measurement Manager module.
468  *
469  * @date 16-Dec-2005
470  */
measurementMgr_destroy(TI_HANDLE hMeasurementMgr)471 TI_STATUS measurementMgr_destroy(TI_HANDLE hMeasurementMgr)
472 {
473     measurementMgr_t *pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
474 
475     if (pMeasurementMgr == NULL)
476         return TI_OK;
477 
478     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr is being destroyed\n");
479 
480     measurementMgr_releaseModule (pMeasurementMgr);
481 
482     return TI_OK;
483 }
484 
485 
486 
487 
488 
489 
490 /**
491  * Sets the Measurement Mode.
492  *
493  * @param hMeasurementMgr A handle to the Measurement Manager module.
494  * @param capabilities The AP capabilities.
495  * @param pIeBuffer Pointer to the list of IEs.
496  * @param length Length of the IE list.
497  *
498  * @date 16-Dec-2005
499  */
measurementMgr_setMeasurementMode(TI_HANDLE hMeasurementMgr,TI_UINT16 capabilities,TI_UINT8 * pIeBuffer,TI_UINT16 length)500 TI_STATUS measurementMgr_setMeasurementMode(TI_HANDLE hMeasurementMgr, TI_UINT16 capabilities,
501                                          TI_UINT8 * pIeBuffer, TI_UINT16 length)
502 {
503     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
504 
505     /*
506      * 11h Measurement is not supported in the current version.
507      */
508 /*  if( (pMeasurementMgr->Capabilities & MEASUREMENT_CAPABILITIES_DOT11H) &&
509         (capabilities & DOT11_SPECTRUM_MANAGEMENT) )
510     {
511         pMeasurementMgr->Mode = MSR_MODE_SPECTRUM_MANAGEMENT;
512     }
513     else
514     {
515 */
516 #ifdef XCC_MODULE_INCLUDED
517 
518         if(pMeasurementMgr->Capabilities & MEASUREMENT_CAPABILITIES_XCC_RM)
519         {
520                     pMeasurementMgr->Mode = MSR_MODE_XCC;
521         }
522         else
523 #endif
524         {
525             pMeasurementMgr->Mode = MSR_MODE_NONE;
526         }
527 
528 
529     TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr mode changed to: %d\n", pMeasurementMgr->Mode);
530 
531     return TI_OK;
532 }
533 
534 
535 
536 
537 
538 
539 /**
540  * Called when a frame with type measurement request is received.
541  *
542  * @param hMeasurementMgr A handle to the Measurement Manager module.
543  * @param frameType The frame type.
544  * @param dataLen The length of the frame.
545  * @param pData A pointer to the frame's content.
546  *
547  * @date 16-Dec-2005
548  */
measurementMgr_receiveFrameRequest(TI_HANDLE hMeasurementMgr,EMeasurementFrameType frameType,TI_INT32 dataLen,TI_UINT8 * pData)549 TI_STATUS measurementMgr_receiveFrameRequest(TI_HANDLE hMeasurementMgr,
550                                              EMeasurementFrameType frameType,
551                                              TI_INT32 dataLen,
552                                              TI_UINT8 * pData)
553 {
554     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
555 
556     TMeasurementFrameRequest * frame = &(pMeasurementMgr->newFrameRequest);
557     TI_UINT16 currentFrameToken;
558 
559     /* checking if measurement is enabled */
560     if (pMeasurementMgr->Mode == MSR_MODE_NONE)
561         return TI_NOK;
562 
563     /* ignore broadcast/multicast request if unicast request is active */
564     if (frameType != MSR_FRAME_TYPE_UNICAST && pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
565     {
566         TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Broadcast/Multicast measurement frame has been ignored\n");
567 
568         return TI_NOK;
569     }
570 
571     /* ignore broadcast request if multicast request is active */
572     if (frameType == MSR_FRAME_TYPE_BROADCAST && pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_MULTICAST)
573     {
574         TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Broadcast measurement frame has been ignored\n");
575 
576         return TI_NOK;
577     }
578 
579     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measurement frame received\n");
580 
581     /* Parsing the Frame Request Header */
582     pMeasurementMgr->parserFrameReq(hMeasurementMgr, pData, dataLen,
583                                         frame);
584 
585     frame->frameType = frameType;
586 
587     /* checking if the received token frame is the same as the one that is being processed */
588     if ((requestHandler_getFrameToken(pMeasurementMgr->hRequestH, &currentFrameToken) == TI_OK)
589         && (currentFrameToken == frame->hdr->dialogToken))
590     {
591         os_memoryZero(pMeasurementMgr->hOs, &pMeasurementMgr->newFrameRequest,
592                       sizeof(TMeasurementFrameRequest));
593 
594         TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measurement frame token %d is identical to current frame token - ignoring frame\n", currentFrameToken);
595 
596         return TI_NOK;
597     }
598 
599     TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measurement frame token is %d\n", frame->hdr->dialogToken);
600 
601     /* Frame is Received for processing */
602     return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
603                                MEASUREMENTMGR_EVENT_FRAME_RECV, pMeasurementMgr);
604 }
605 
606 
607 
608 
609 
610 /**
611  * Activates the next measurement request.
612  *
613  * @param hMeasurementMgr A handle to the Measurement Manager module.
614  *
615  * @date 16-Dec-2005
616  */
measurementMgr_activateNextRequest(TI_HANDLE hMeasurementMgr)617 TI_STATUS measurementMgr_activateNextRequest(TI_HANDLE hMeasurementMgr)
618 {
619     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
620     requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
621     MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
622     TI_UINT8 numOfRequestsInParallel = 0;
623     TI_BOOL valid;
624     TI_UINT8 index;
625 
626 	/* Keep note of the time we started processing the request. this will be used */
627     /* to give the measurementSRV a time frame to perform the measurement operation */
628     pMeasurementMgr->currentRequestStartTime = os_timeStampMs(pMeasurementMgr->hOs);
629 
630     TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Timer started at %d, we have 20ms to begin measurement...\n", pMeasurementMgr->currentRequestStartTime);
631 
632     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Looking for a valid request\n");
633 
634     do
635     {
636         TI_STATUS status;
637 
638         if (numOfRequestsInParallel != 0)
639         {
640             TRACE4(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Changing activeRequestID from %d to %d, and numOfWaitingRequests from %d to %d.\n", pRequestH->activeRequestID, pRequestH->activeRequestID + numOfRequestsInParallel, pRequestH->numOfWaitingRequests, pRequestH->numOfWaitingRequests - numOfRequestsInParallel);
641         }
642 
643         pRequestH->activeRequestID += numOfRequestsInParallel;
644         pRequestH->numOfWaitingRequests -= numOfRequestsInParallel;
645 
646         for (index = 0; index < MAX_NUM_REQ; index++)
647         {
648             pRequestArr[index] = NULL;
649         }
650         numOfRequestsInParallel = 0;
651 
652         /* Getting the next request/requests from the request handler */
653         status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, TI_FALSE, pRequestArr,
654                                            &numOfRequestsInParallel);
655 
656         /* Checking if there are no waiting requests */
657         if (status != TI_OK)
658         {
659             TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": There are no waiting requests in the queue\n");
660 
661             return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
662                                MEASUREMENTMGR_EVENT_SEND_REPORT, pMeasurementMgr);
663         }
664 
665         /* Checking validity of request/s */
666         valid = measurementMgr_isRequestValid(pMeasurementMgr, pRequestArr,
667                                 numOfRequestsInParallel);
668 
669         /* Checking if the current request is Beacon Table */
670         if( (numOfRequestsInParallel == 1) &&
671             (pRequestArr[0]->Type == MSR_TYPE_BEACON_MEASUREMENT) &&
672             (pRequestArr[0]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE) )
673         {
674             TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received Beacon Table request, building a report for it and continuing\n");
675 
676             pMeasurementMgr->buildReport(hMeasurementMgr, *(pRequestArr[0]), NULL);
677             valid = TI_FALSE; /* In order to get the next request/s*/
678         }
679 
680     } while (valid == TI_FALSE);
681 
682 
683     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Request(s) for activation:\n");
684 
685     for (index = 0; index < numOfRequestsInParallel; index++)
686     {
687         TRACE6(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": \n\nRequest #%d:\n Type: %d\n Measured Channel: %d (Serving Channel: %d)\n Scan Mode: %d\n Duration: %d\n\n", index+1, pRequestArr[index]->Type, pRequestArr[index]->channelNumber, pMeasurementMgr->servingChannelID, pRequestArr[index]->ScanMode, pRequestArr[index]->DurationTime);
688     }
689 
690     /* Ignore requests if traffic intensity is high */
691     if (measurementMgr_isTrafficIntensityHigherThanThreshold(pMeasurementMgr) == TI_TRUE)
692     {
693         TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Traffic intensity too high, giving up...\n");
694 
695         measurementMgr_rejectPendingRequests(pMeasurementMgr, MSR_REJECT_TRAFFIC_INTENSITY_TOO_HIGH);
696 
697         return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
698                                MEASUREMENTMGR_EVENT_SEND_REPORT, pMeasurementMgr);
699     }
700 
701     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Request is Valid, about to start\n");
702 
703     pMeasurementMgr->measuredChannelID = pRequestArr[0]->channelNumber;
704 
705     /* Request resource from the SCR */
706     return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
707         MEASUREMENTMGR_EVENT_REQUEST_SCR, pMeasurementMgr);
708 }
709 
710 
711 
measurementMgr_rejectPendingRequests(TI_HANDLE hMeasurementMgr,EMeasurementRejectReason rejectReason)712 void measurementMgr_rejectPendingRequests(TI_HANDLE hMeasurementMgr, EMeasurementRejectReason rejectReason)
713 {
714     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
715     requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
716     MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
717     TI_UINT8 numOfRequestsInParallel;
718 
719     /* reject all pending measurement requests */
720     while (requestHandler_getNextReq(pMeasurementMgr->hRequestH, TI_TRUE,
721                 pRequestArr, &numOfRequestsInParallel) == TI_OK)
722     {
723         TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Rejecting pending request (activeRequestID = %d)...\n", pRequestH->activeRequestID);
724 
725         pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr,
726                 numOfRequestsInParallel, rejectReason);
727 
728         pRequestH->activeRequestID += numOfRequestsInParallel;
729     }
730 }
731 
732 
733 
734 
735 
736 /********************************************************************************/
737 /*                      Callback functions Implementation.                      */
738 /********************************************************************************/
739 
740 
741 /**
742  * The callback called by the MeasurementSRV module when then
743  * measurement operation has ended.
744  *
745  * @param clientObj A handle to the Measurement Manager module.
746  * @param msrReply An array of replies sent by the MeasurementSRV module,
747  * where each reply contains the result of a single measurement request.
748  *
749  * @date 01-Jan-2006
750  */
measurementMgr_MeasurementCompleteCB(TI_HANDLE clientObj,TMeasurementReply * msrReply)751 void measurementMgr_MeasurementCompleteCB(TI_HANDLE clientObj, TMeasurementReply * msrReply)
752 {
753     measurementMgr_t    *pMeasurementMgr = (measurementMgr_t *) clientObj;
754     TI_UINT8            index;
755 
756     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Building reports for measurement requests\n");
757 
758     /* build a report for each measurement request/reply pair */
759     for (index = 0; index < msrReply->numberOfTypes; index++)
760     {
761         pMeasurementMgr->buildReport(pMeasurementMgr, *(pMeasurementMgr->currentRequest[index]), &msrReply->msrTypes[index]);
762     }
763 
764     measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
765             MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);
766 }
767 
768 
769 /**
770  * The callback called when the SCR responds to the SCR request.
771  *
772  * @param hClient A handle to the Measurement Manager module.
773  * @param requestStatus The request's status
774  * @param eResource The resource for which the CB is issued
775  * @param pendReason The reason of a PEND status.
776  *
777  * @date 01-Jan-2006
778  */
measurementMgr_scrResponseCB(TI_HANDLE hClient,EScrClientRequestStatus requestStatus,EScrResourceId eResource,EScePendReason pendReason)779 void measurementMgr_scrResponseCB(TI_HANDLE hClient, EScrClientRequestStatus requestStatus,
780                                   EScrResourceId eResource, EScePendReason pendReason )
781 {
782     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hClient;
783     measurementMgrSM_Events event;
784 
785     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": SCR callback entered\n");
786 
787     /* If the SM is in a state where it waits for the CB, status of RUN */
788     /* results in the SM asking the measurementSRV to start measurement; */
789     /* otherwise we got an ABORT or a PEND reason worse than the one we */
790     /* got when calling the SCR, so the SM aborts the measurement */
791     if (pMeasurementMgr->currentState == MEASUREMENTMGR_STATE_WAITING_FOR_SCR)
792     {
793         if (requestStatus == SCR_CRS_RUN)
794         {
795             TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received SCR status RUN, running...\n");
796 
797             event = MEASUREMENTMGR_EVENT_SCR_RUN;
798         }
799         else
800         {
801             if (requestStatus == SCR_CRS_PEND)
802             {
803                 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received SCR status PEND with reason %d, aborting...\n", pendReason);
804             }
805             else
806             {
807                 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received SCR status ABORT/FW_RESET, aborting...\n");
808             }
809 
810             event = MEASUREMENTMGR_EVENT_ABORT;
811         }
812     }
813     else
814     {
815         /* This can only occur if FW reset occurs or when higher priority client is running. */
816 
817         if (requestStatus == SCR_CRS_FW_RESET)
818         {
819             TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received SCR status FW_RESET\n");
820 
821             event = MEASUREMENTMGR_EVENT_FW_RESET;
822         }
823         else
824         {
825         TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgrSM current state is %d (which isn't WAITING_FOR_SCR), aborting...\n", pMeasurementMgr->currentState);
826 
827         event = MEASUREMENTMGR_EVENT_ABORT;
828     }
829     }
830 
831     measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
832         event, pMeasurementMgr);
833 }
834 
835 
836 
837 
838 
839 
840 /**
841  * The callback called by the MLME.
842  *
843  * @param hMeasurementMgr A handle to the Measurement Manager module.
844  *
845  * @date 01-Jan-2006
846  */
measurementMgr_mlmeResultCB(TI_HANDLE hMeasurementMgr,TMacAddr * bssid,mlmeFrameInfo_t * frameInfo,TRxAttr * pRxAttr,TI_UINT8 * buffer,TI_UINT16 bufferLength)847 void measurementMgr_mlmeResultCB(TI_HANDLE hMeasurementMgr, TMacAddr * bssid, mlmeFrameInfo_t * frameInfo,
848                                  TRxAttr * pRxAttr, TI_UINT8 * buffer, TI_UINT16 bufferLength)
849 {
850     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
851     TScanFrameInfo      tScanFrameInfo;
852 
853 	if (measurementMgrSM_measureInProgress(pMeasurementMgr) == TI_FALSE)
854 	{
855 		TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION , "measurementMgr_mlmeResultCB: measurement not in progress, return\n");
856 		return;
857 	}
858 
859 
860 	/* erroneous frames are notifed to the measurmenet manager to update counter
861     (add counter sometimes in the future) Look at: scanCncn_ScanCompleteNotificationCB and
862     scanCncn_MlmeResultCB */
863     if (NULL == bssid)
864     {
865         TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION , "measurementMgr_mlmeResultCB: received an empty frame notification from MLME\n");
866         return;
867     }
868 
869     if (pMeasurementMgr == NULL || pRxAttr == NULL)
870     {
871 		if(pMeasurementMgr != NULL)
872 		{
873 			TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": MLME callback called with NULL object\n");
874 		}
875         return;
876     }
877 
878     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MLME callback entered\n");
879 
880     /* build the scan frame info object */
881     tScanFrameInfo.bssId = bssid;
882     tScanFrameInfo.band = (ERadioBand)pRxAttr->band;
883     tScanFrameInfo.channel = pRxAttr->channel;
884     tScanFrameInfo.parsedIEs = frameInfo;
885     tScanFrameInfo.rate = pRxAttr->Rate;
886     tScanFrameInfo.rssi = pRxAttr->Rssi;
887     tScanFrameInfo.snr = pRxAttr->SNR;
888     tScanFrameInfo.staTSF = pRxAttr->TimeStamp;
889     tScanFrameInfo.buffer = buffer;
890     tScanFrameInfo.bufferLength = bufferLength;
891 
892     /* update the driver (SME) result table */
893     sme_MeansurementScanResult (pMeasurementMgr->hSme, SCAN_CRS_RECEIVED_FRAME, &tScanFrameInfo);
894 
895     TRACE8(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MLME Frame: Subtype = %d, MAC = %x-%x-%x-%x-%x-%x, RSSI = %d\n", frameInfo->subType, (*bssid)[0], (*bssid)[1], (*bssid)[2], (*bssid)[3], (*bssid)[4], (*bssid)[5], pRxAttr->Rssi);
896 }
897 
898 
899 /********************************************************************************/
900 /*                      Internal functions Implementation.                      */
901 /********************************************************************************/
902 
903 
904 /**
905  * Releases the module's allocated objects according to the given init vector.
906  *
907  * @param pMeasurementMgr A handle to the Measurement Manager module.
908  * @param initVec The init vector with a bit set for each allocated object.
909  *
910  * @date 01-Jan-2006
911  */
measurementMgr_releaseModule(measurementMgr_t * pMeasurementMgr)912 static void measurementMgr_releaseModule (measurementMgr_t * pMeasurementMgr)
913 {
914 #ifdef XCC_MODULE_INCLUDED
915     TI_UINT32 currAC;
916 #endif
917 
918     if (pMeasurementMgr->hActivationDelayTimer)
919     {
920         tmr_DestroyTimer (pMeasurementMgr->hActivationDelayTimer);
921     }
922 
923 #ifdef XCC_MODULE_INCLUDED
924     for (currAC = 0; currAC < MAX_NUM_OF_AC; currAC++)
925     {
926         if (pMeasurementMgr->hTsMetricsReportTimer[currAC])
927         {
928             tmr_DestroyTimer (pMeasurementMgr->hTsMetricsReportTimer[currAC]);
929         }
930     }
931 #endif
932 
933     if (pMeasurementMgr->pMeasurementMgrSm)
934     {
935         fsm_Unload(pMeasurementMgr->hOs, pMeasurementMgr->pMeasurementMgrSm);
936     }
937 
938     if (pMeasurementMgr->hRequestH)
939     {
940         requestHandler_destroy(pMeasurementMgr->hRequestH);
941     }
942 
943     os_memoryFree(pMeasurementMgr->hOs, pMeasurementMgr, sizeof(measurementMgr_t));
944 }
945 
946 
947 
948 /**
949  * Checks whether the traffic intensity, i.e. number of packets per seconds, is higher
950  * than the preconfigured threshold.
951  *
952  * @param pMeasurementMgr A handle to the Measurement Manager module.
953  *
954  * @return True iff the traffic intensity is high
955  *
956  * @date 01-Jan-2006
957  */
measurementMgr_isTrafficIntensityHigherThanThreshold(measurementMgr_t * pMeasurementMgr)958 static TI_BOOL measurementMgr_isTrafficIntensityHigherThanThreshold(measurementMgr_t * pMeasurementMgr)
959 {
960     TI_BOOL trafficIntensityHigh = TI_FALSE;
961     int pcksPerSec;
962 
963     pcksPerSec = TrafficMonitor_GetFrameBandwidth(pMeasurementMgr->hTrafficMonitor);
964 
965     TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": pcksPerSec = %d\n", pcksPerSec);
966 
967     if (pcksPerSec >= pMeasurementMgr->trafficIntensityThreshold)
968         trafficIntensityHigh = TI_TRUE;
969 
970     return trafficIntensityHigh;
971 }
972 
973 
974 
975 
976 /**
977  * Checks whether the given measurement request is valid.
978  *
979  * @param hMeasurementMgr A handle to the Measurement Manager module.
980  * @param pRequestArr The measurement request.
981  * @param numOfRequest Number of type requests
982  *
983  * @return True iff the request is valid
984  *
985  * @date 01-Jan-2006
986  */
measurementMgr_isRequestValid(TI_HANDLE hMeasurementMgr,MeasurementRequest_t * pRequestArr[],TI_UINT8 numOfRequest)987 static TI_BOOL  measurementMgr_isRequestValid(TI_HANDLE hMeasurementMgr, MeasurementRequest_t *pRequestArr[],
988                            TI_UINT8 numOfRequest)
989 {
990     measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
991     TI_UINT8 requestIndex;
992     paramInfo_t param;
993 
994     /* Checking validity of the measured channel number */
995     param.content.channel = pRequestArr[0]->channelNumber;
996     param.paramType = REGULATORY_DOMAIN_IS_CHANNEL_SUPPORTED;
997     regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, &param);
998     if ( !param.content.bIsChannelSupprted  )
999     {
1000         TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Request rejected due to invalid channel\n");
1001 
1002         if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
1003             pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest,
1004                                     MSR_REJECT_INVALID_CHANNEL);
1005 
1006         return TI_FALSE;
1007     }
1008     else
1009     {
1010         TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Request channel is Valid\n");
1011     }
1012 
1013     TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Starting to check each request:\n");
1014 
1015     /* Check Validity of each request */
1016     for (requestIndex = 0; requestIndex < numOfRequest; requestIndex++)
1017     {
1018         TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Checking request #%d:\n", requestIndex+1);
1019 
1020         /* Checking validity of the Request Type */
1021         if (pMeasurementMgr->isTypeValid(hMeasurementMgr, pRequestArr[requestIndex]->Type,
1022                 pRequestArr[requestIndex]->ScanMode) == TI_FALSE)
1023         {
1024             TRACE2(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Request rejected due to invalid measurement type of request #%d (type = %d)\n", requestIndex+1, pRequestArr[requestIndex]->Type);
1025 
1026             if(pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
1027                 pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest,
1028                                         MSR_REJECT_INVALID_MEASUREMENT_TYPE);
1029 
1030             return TI_FALSE;
1031         }
1032         else
1033         {
1034             TRACE2(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measurement type of request #%d is supported (type = %d)\n", requestIndex+1, pRequestArr[requestIndex]->Type);
1035         }
1036 
1037         /* For measurement types different than Beacon Table */
1038         if ((pRequestArr[requestIndex]->Type != MSR_TYPE_BEACON_MEASUREMENT) ||
1039             (pRequestArr[requestIndex]->ScanMode != MSR_SCAN_MODE_BEACON_TABLE))
1040         {
1041             /* Checking Measurement request's duration only when request is on a non-serving channel */
1042             if (pMeasurementMgr->servingChannelID != pRequestArr[requestIndex]->channelNumber)
1043             {
1044                 TI_UINT8 dtimPeriod;
1045                 TI_UINT32 beaconInterval;
1046                 TI_UINT32 dtimDuration;
1047 
1048 
1049                 /* Checking duration doesn't exceed given max duration */
1050                 if (pRequestArr[requestIndex]->DurationTime > pMeasurementMgr->maxDurationOnNonServingChannel)
1051                 {
1052                     TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Request #%d rejected because duration exceeds maximum duration\n", requestIndex+1);
1053 
1054                     TRACE2(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Duration = %d, MaxDurationOnNonServingChannel = %d\n", pRequestArr[requestIndex]->DurationTime, pMeasurementMgr->maxDurationOnNonServingChannel);
1055 
1056                     if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
1057                         pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest,
1058                                 MSR_REJECT_DURATION_EXCEED_MAX_DURATION);
1059 
1060                     return TI_FALSE;
1061                 }
1062                 else
1063                 {
1064                     TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Duration of request #%d doesn't exceed max duration\n", requestIndex+1);
1065                 }
1066 
1067 
1068                 /* Checking DTIM */
1069 
1070                 /* Getting the DTIM count */
1071                 param.paramType = SITE_MGR_DTIM_PERIOD_PARAM;
1072                 siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
1073                 dtimPeriod = param.content.siteMgrDtimPeriod;
1074 
1075                 /* Getting the beacon Interval */
1076                 param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
1077                 siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
1078                 beaconInterval = param.content.beaconInterval;
1079 
1080                 dtimDuration = beaconInterval * MEASUREMENT_BEACON_INTERVAL_IN_MICRO_SEC/MEASUREMENT_MSEC_IN_MICRO*dtimPeriod;
1081                 if (pRequestArr[requestIndex]->DurationTime > dtimDuration)
1082                 {
1083                     TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_WARNING, ": Request rejected due to DTIM overlap of request #%d\n", requestIndex+1);
1084 
1085                     TRACE2(pMeasurementMgr->hReport, REPORT_SEVERITY_WARNING, ": Duration = %d, DTIM Duration = %d\n", pRequestArr[requestIndex]->DurationTime, dtimDuration);
1086 
1087                     if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
1088                         pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest,
1089                                                 MSR_REJECT_DTIM_OVERLAP);
1090 
1091                     return TI_FALSE;
1092                 }
1093                 else
1094                 {
1095                     TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": DTIM of request #%d doesn't overlap\n", requestIndex+1);
1096                 }
1097             }
1098         }
1099     }
1100 
1101     return TI_TRUE;
1102 }
1103 
measurementMgrSM_measureInProgress(TI_HANDLE hMeasurementMgr)1104 static TI_BOOL measurementMgrSM_measureInProgress(TI_HANDLE hMeasurementMgr)
1105 {
1106 	measurementMgr_t * pMeasurementMgr = (measurementMgr_t *)hMeasurementMgr;
1107 
1108 	if (pMeasurementMgr->currentState == MEASUREMENTMGR_STATE_MEASURING)
1109 		return TI_TRUE;
1110 
1111 	else
1112 		return TI_FALSE;
1113 }
1114 
1115 
1116