PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/Management/AirLink/Measurement/measurementMgr.c

http://github.com/CyanogenMod/cm-kernel
C | 1242 lines | 676 code | 303 blank | 263 comment | 106 complexity | f36b83239e96f2fb2e6b88704fd96943 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 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. #include "measurementMgr.h"
  42. #include "regulatoryDomainApi.h"
  43. #include "healthMonitor.h"
  44. #include "siteMgrApi.h"
  45. #include "utils.h"
  46. #include "TrafficMonitorAPI.h"
  47. #include "smeApi.h"
  48. #ifdef EXC_MODULE_INCLUDED
  49. #include "excTSMngr.h"
  50. #endif
  51. /* allocation vector */
  52. #define MEASUREMENT_INIT_BIT (1)
  53. #define MEASUREMENT_ACTIVATION_DELAY_TIMER_INIT_BIT (2)
  54. #define MEASUREMENT_SM_INIT_BIT (3)
  55. #define MEASUREMENT_REQUEST_HANDLER_SUB_MODULE_INIT_BIT (4)
  56. /* default measurement parameters */
  57. #define MEASUREMENT_CAPABILITIES_NONE 0x00
  58. #define MEASUREMENT_CAPABILITIES_DOT11H 0x01
  59. #define MEASUREMENT_CAPABILITIES_EXC_RM 0x02
  60. #define MEASUREMENT_BEACON_INTERVAL_IN_MICRO_SEC 1024
  61. #define MEASUREMENT_MSEC_IN_MICRO 1000
  62. /********************************************************************************/
  63. /* Internal functions prototypes. */
  64. /********************************************************************************/
  65. static void measurementMgr_releaseModule(measurementMgr_t * pMeasurementMgr, UINT32 initVec);
  66. static BOOL measurementMgr_isTrafficIntensityHigherThanThreshold(measurementMgr_t * pMeasurementMgr);
  67. static BOOL measurementMgr_isRequestValid(TI_HANDLE hMeasurementMgr, MeasurementRequest_t *pRequestArr[], UINT8 numOfRequest);
  68. static void measurementMgr_uponActivationDelayTimeout(TI_HANDLE Context);
  69. /********************************************************************************/
  70. /* Interface functions Implementation. */
  71. /********************************************************************************/
  72. /**
  73. * Creates the Measurement Manager moodule.
  74. *
  75. * @param hOs A handle to the OS object.
  76. *
  77. * @date 16-Dec-2005
  78. */
  79. TI_HANDLE measurementMgr_create(TI_HANDLE hOs)
  80. {
  81. measurementMgr_t * pMeasurementMgr = NULL;
  82. UINT32 initVec = 0;
  83. TI_STATUS status;
  84. /* allocating the MeasurementMgr object */
  85. pMeasurementMgr = os_memoryAlloc(hOs, sizeof(measurementMgr_t));
  86. if (pMeasurementMgr == NULL)
  87. return NULL;
  88. os_memoryZero(hOs, pMeasurementMgr, sizeof(measurementMgr_t));
  89. pMeasurementMgr->hOs = hOs;
  90. initVec |= (1 << MEASUREMENT_INIT_BIT);
  91. /* allocating the measurement Activation Delay timer */
  92. pMeasurementMgr->pActivationDelayTimer = os_timerCreate(hOs, measurementMgr_uponActivationDelayTimeout,
  93. pMeasurementMgr);
  94. if (pMeasurementMgr->pActivationDelayTimer == NULL)
  95. {
  96. measurementMgr_releaseModule(pMeasurementMgr, initVec);
  97. return NULL;
  98. }
  99. initVec |= (1<<MEASUREMENT_ACTIVATION_DELAY_TIMER_INIT_BIT);
  100. #ifdef EXC_MODULE_INCLUDED
  101. if ((pMeasurementMgr->pTsMetricsReportTimer[QOS_AC_BE] =
  102. os_timerCreate(hOs, measurementMgr_sendTSMReport_AC_BE, pMeasurementMgr)) == NULL)
  103. {
  104. measurementMgr_releaseModule(pMeasurementMgr, initVec);
  105. return NULL;
  106. }
  107. if ((pMeasurementMgr->pTsMetricsReportTimer[QOS_AC_BK] =
  108. os_timerCreate(hOs, measurementMgr_sendTSMReport_AC_BK, pMeasurementMgr)) == NULL)
  109. {
  110. measurementMgr_releaseModule(pMeasurementMgr, initVec);
  111. return NULL;
  112. }
  113. if ((pMeasurementMgr->pTsMetricsReportTimer[QOS_AC_VI] =
  114. os_timerCreate(hOs, measurementMgr_sendTSMReport_AC_VI, pMeasurementMgr)) == NULL)
  115. {
  116. measurementMgr_releaseModule(pMeasurementMgr, initVec);
  117. return NULL;
  118. }
  119. if ((pMeasurementMgr->pTsMetricsReportTimer[QOS_AC_VO] =
  120. os_timerCreate(hOs, measurementMgr_sendTSMReport_AC_VO, pMeasurementMgr)) == NULL)
  121. {
  122. measurementMgr_releaseModule(pMeasurementMgr, initVec);
  123. return NULL;
  124. }
  125. #endif
  126. /* creating the Measurement SM */
  127. status = fsm_Create(pMeasurementMgr->hOs, &(pMeasurementMgr->pMeasurementMgrSm),
  128. MEASUREMENTMGR_NUM_STATES , MEASUREMENTMGR_NUM_EVENTS);
  129. if(status != OK)
  130. {
  131. measurementMgr_releaseModule(pMeasurementMgr, initVec);
  132. return NULL;
  133. }
  134. initVec |= (1<<MEASUREMENT_SM_INIT_BIT);
  135. /* creating the sub modules of measurement module */
  136. /* creating Request Handler sub module */
  137. if( (pMeasurementMgr->hRequestH = requestHandler_create(hOs)) == NULL)
  138. {
  139. measurementMgr_releaseModule(pMeasurementMgr, initVec);
  140. return NULL;
  141. }
  142. initVec |= (1<<MEASUREMENT_REQUEST_HANDLER_SUB_MODULE_INIT_BIT);
  143. return(pMeasurementMgr);
  144. }
  145. /**
  146. * Configures the Measurement Manager module.
  147. *
  148. * @param hXXXX Handles to other modules the Measurement Manager needs.
  149. * @param pMeasurementInitParams A pointer to the measurement init parameters.
  150. *
  151. * @date 16-Dec-2005
  152. */
  153. TI_STATUS measurementMgr_config(TI_HANDLE hMeasurementMgr,
  154. TI_HANDLE hMacServices,
  155. TI_HANDLE hRegulatoryDomain,
  156. TI_HANDLE hExcMngr,
  157. TI_HANDLE hSiteMgr,
  158. TI_HANDLE hHalCtrl,
  159. TI_HANDLE hMlme,
  160. TI_HANDLE hTrafficMonitor,
  161. TI_HANDLE hReport,
  162. TI_HANDLE hOs,
  163. TI_HANDLE hScr,
  164. TI_HANDLE hHealthMonitor,
  165. TI_HANDLE hApConn,
  166. TI_HANDLE hTx,
  167. measurementInitParams_t * pMeasurementInitParams)
  168. {
  169. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  170. paramInfo_t param;
  171. TI_STATUS status;
  172. #ifdef EXC_MODULE_INCLUDED
  173. UINT32 currAC;
  174. #endif
  175. /* Init Handlers */
  176. pMeasurementMgr->hMacServices = hMacServices;
  177. pMeasurementMgr->hRegulatoryDomain = hRegulatoryDomain;
  178. pMeasurementMgr->hExcMngr = hExcMngr;
  179. pMeasurementMgr->hSiteMgr = hSiteMgr;
  180. pMeasurementMgr->hHalCtrl = hHalCtrl;
  181. pMeasurementMgr->hMlme = hMlme;
  182. pMeasurementMgr->hTrafficMonitor = hTrafficMonitor;
  183. pMeasurementMgr->hReport = hReport;
  184. pMeasurementMgr->hOs = hOs;
  185. pMeasurementMgr->hScr = hScr;
  186. pMeasurementMgr->hHealthMonitor = hHealthMonitor;
  187. pMeasurementMgr->hApConn = hApConn;
  188. pMeasurementMgr->hTx = hTx;
  189. /* initialize variables to default values */
  190. pMeasurementMgr->Enabled = TRUE;
  191. pMeasurementMgr->Connected = FALSE;
  192. pMeasurementMgr->Capabilities = MEASUREMENT_CAPABILITIES_NONE;
  193. pMeasurementMgr->Mode = MSR_MODE_NONE;
  194. /* Getting management capability status */
  195. param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
  196. regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, &param);
  197. if (param.content.spectrumManagementEnabled)
  198. {
  199. pMeasurementMgr->Capabilities |= MEASUREMENT_CAPABILITIES_DOT11H;
  200. }
  201. #ifdef EXC_MODULE_INCLUDED
  202. /* Check in the Registry if the station supports EXC RM */
  203. if (pMeasurementInitParams->excEnabled == EXC_MODE_ENABLED)
  204. {
  205. pMeasurementMgr->Capabilities |= MEASUREMENT_CAPABILITIES_EXC_RM;
  206. }
  207. #endif
  208. /* Init Functions */
  209. pMeasurementMgr->parserFrameReq = NULL;
  210. pMeasurementMgr->isTypeValid = NULL;
  211. pMeasurementMgr->buildReport = NULL;
  212. pMeasurementMgr->buildRejectReport = NULL;
  213. pMeasurementMgr->sendReportAndCleanObj = NULL;
  214. /* initialize variables */
  215. pMeasurementMgr->currentState = MEASUREMENTMGR_STATE_IDLE;
  216. pMeasurementMgr->isModuleRegistered = FALSE;
  217. pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
  218. pMeasurementMgr->measuredChannelID = 0;
  219. pMeasurementMgr->currentNumOfRequestsInParallel = 0;
  220. pMeasurementMgr->trafficIntensityThreshold = pMeasurementInitParams->trafficIntensityThreshold;
  221. pMeasurementMgr->maxDurationOnNonServingChannel = pMeasurementInitParams->maxDurationOnNonServingChannel;
  222. /* config sub modules */
  223. RequestHandler_config(pMeasurementMgr->hRequestH, hReport, hOs);
  224. /* Register to the SCR module */
  225. scr_registerClientCB(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE, measurementMgr_scrResponseCB, pMeasurementMgr);
  226. #ifdef EXC_MODULE_INCLUDED
  227. for (currAC = 0; currAC < MAX_NUM_OF_AC; currAC++)
  228. {
  229. pMeasurementMgr->isTsMetricsEnabled[currAC] = FALSE;
  230. os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pTsMetricsReportTimer[currAC]);
  231. }
  232. #endif
  233. status = measurementMgrSM_config(hMeasurementMgr);
  234. if(status == OK)
  235. {
  236. WLAN_REPORT_INIT(hReport, MEASUREMENT_MNGR_MODULE_LOG,
  237. ("%s: Measurement Manager configured successfully\n", __FUNCTION__));
  238. }
  239. else
  240. {
  241. WLAN_REPORT_ERROR(hReport, MEASUREMENT_MNGR_MODULE_LOG,
  242. ("%s: Measurement Manager configuration failed\n", __FUNCTION__));
  243. }
  244. return status;
  245. }
  246. /**
  247. * Sets the specified Measurement Manager parameter.
  248. *
  249. * @param hMeasurementMgr A handle to the Measurement Manager module.
  250. * @param pParam The parameter to set.
  251. *
  252. * @date 16-Dec-2005
  253. */
  254. TI_STATUS measurementMgr_setParam(TI_HANDLE hMeasurementMgr, paramInfo_t * pParam)
  255. {
  256. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  257. switch (pParam->paramType)
  258. {
  259. case MEASUREMENT_ENABLE_DISABLE_PARAM:
  260. {
  261. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  262. ("%s: MEASUREMENT_ENABLE_DISABLE_PARAM <- %d\n", __FUNCTION__, pParam->content.measurementEnableDisableStatus));
  263. if (pParam->content.measurementEnableDisableStatus)
  264. {
  265. measurementMgr_enable(pMeasurementMgr);
  266. }
  267. else
  268. {
  269. measurementMgr_disable(pMeasurementMgr);
  270. }
  271. break;
  272. }
  273. case MEASUREMENT_TRAFFIC_THRESHOLD_PARAM:
  274. {
  275. if ((pParam->content.measurementTrafficThreshold >= MEASUREMENT_TRAFFIC_THRSHLD_MIN) &&
  276. (pParam->content.measurementTrafficThreshold <= MEASUREMENT_TRAFFIC_THRSHLD_MAX))
  277. {
  278. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  279. ("%s: MEASUREMENT_TRAFFIC_THRESHOLD_PARAM <- %d\n", __FUNCTION__, pParam->content.measurementTrafficThreshold));
  280. pMeasurementMgr->trafficIntensityThreshold = pParam->content.measurementTrafficThreshold;
  281. }
  282. else
  283. {
  284. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  285. ("%s: Invalid value for MEASUREMENT_TRAFFIC_THRESHOLD_PARAM (%d)\n", __FUNCTION__, pParam->content.measurementTrafficThreshold));
  286. }
  287. break;
  288. }
  289. case MEASUREMENT_MAX_DURATION_PARAM:
  290. {
  291. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  292. ("%s: MEASUREMENT_MAX_DURATION_PARAM <- %d\n", __FUNCTION__, pParam->content.measurementMaxDuration));
  293. pMeasurementMgr->maxDurationOnNonServingChannel = pParam->content.measurementMaxDuration;
  294. break;
  295. }
  296. default:
  297. {
  298. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  299. ("%s: Specified parameter is not supported (%d)\n", __FUNCTION__, pParam->paramType));
  300. return PARAM_NOT_SUPPORTED;
  301. }
  302. }
  303. return OK;
  304. }
  305. /**
  306. * Gets the specified parameter from the Measurement Manager.
  307. *
  308. * @param hMeasurementMgr A handle to the Measurement Manager module.
  309. * @param pParam The parameter to get.
  310. *
  311. * @date 16-Dec-2005
  312. */
  313. TI_STATUS measurementMgr_getParam(TI_HANDLE hMeasurementMgr, paramInfo_t * pParam)
  314. {
  315. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  316. switch(pParam->paramType)
  317. {
  318. case MEASUREMENT_GET_STATUS_PARAM:
  319. {
  320. WLAN_OS_REPORT(("%s: \n\n", __FUNCTION__));
  321. WLAN_OS_REPORT(("MeasurementMgr Status Report:\n\n"));
  322. WLAN_OS_REPORT(("Current State: %d\n\n", pMeasurementMgr->currentState));
  323. WLAN_OS_REPORT(("Connected: %d\n", pMeasurementMgr->Connected));
  324. WLAN_OS_REPORT(("Enabled: %d\n\n", pMeasurementMgr->Enabled));
  325. WLAN_OS_REPORT(("Mode: %d\n", pMeasurementMgr->Mode));
  326. WLAN_OS_REPORT(("Capabilities: %d\n\n", pMeasurementMgr->Capabilities));
  327. WLAN_OS_REPORT(("current Frame Type: %d\n", pMeasurementMgr->currentFrameType));
  328. WLAN_OS_REPORT(("Measured Channel: %d\n", pMeasurementMgr->measuredChannelID));
  329. WLAN_OS_REPORT(("Serving Channel: %d\n", pMeasurementMgr->servingChannelID));
  330. WLAN_OS_REPORT(("Traffic Intensity Threshold: %d\n", pMeasurementMgr->trafficIntensityThreshold));
  331. WLAN_OS_REPORT(("Max Duration on Nonserving Channel: %d\n", pMeasurementMgr->maxDurationOnNonServingChannel));
  332. break;
  333. }
  334. default:
  335. {
  336. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  337. ("%s: Specified parameter is not supported (%d)\n", __FUNCTION__, pParam->paramType));
  338. return PARAM_NOT_SUPPORTED;
  339. }
  340. }
  341. return OK;
  342. }
  343. /**
  344. * Signals the Measurement Manager that the STA is connected.
  345. *
  346. * @param hMeasurementMgr A handle to the Measurement Manager module.
  347. *
  348. * @date 16-Dec-2005
  349. */
  350. TI_STATUS measurementMgr_connected(TI_HANDLE hMeasurementMgr)
  351. {
  352. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  353. /* checking if measurement is enabled */
  354. if (pMeasurementMgr->Mode == MSR_MODE_NONE)
  355. return OK;
  356. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  357. ("%s: MeasurementMgr set to connected.\n", __FUNCTION__));
  358. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  359. MEASUREMENTMGR_EVENT_CONNECTED, pMeasurementMgr);
  360. }
  361. /**
  362. * Signals the Measurement Manager that the STA is disconnected.
  363. *
  364. * @param hMeasurementMgr A handle to the Measurement Manager module.
  365. *
  366. * @date 16-Dec-2005
  367. */
  368. TI_STATUS measurementMgr_disconnected(TI_HANDLE hMeasurementMgr)
  369. {
  370. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  371. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  372. ("%s: MeasurementMgr set to disconnected.\n", __FUNCTION__));
  373. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  374. MEASUREMENTMGR_EVENT_DISCONNECTED, pMeasurementMgr);
  375. }
  376. /**
  377. * Enables the Measurement Manager module.
  378. *
  379. * @date 10-Jan-2006
  380. */
  381. TI_STATUS measurementMgr_enable(TI_HANDLE hMeasurementMgr)
  382. {
  383. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  384. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  385. ("%s: MeasurementMgr set to enabled.\n", __FUNCTION__));
  386. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  387. MEASUREMENTMGR_EVENT_ENABLE, pMeasurementMgr);
  388. }
  389. /**
  390. * Disables the Measurement Manager module.
  391. *
  392. * @date 10-Jan-2006
  393. */
  394. TI_STATUS measurementMgr_disable(TI_HANDLE hMeasurementMgr)
  395. {
  396. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  397. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  398. ("%s: MeasurementMgr set to disabled.\n", __FUNCTION__));
  399. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  400. MEASUREMENTMGR_EVENT_DISABLE, pMeasurementMgr);
  401. }
  402. /**
  403. * Destroys the Measurement Manager module.
  404. *
  405. * @param hMeasurementMgr A handle to the Measurement Manager module.
  406. *
  407. * @date 16-Dec-2005
  408. */
  409. TI_STATUS measurementMgr_destroy(TI_HANDLE hMeasurementMgr)
  410. {
  411. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  412. UINT32 initVec;
  413. if (pMeasurementMgr == NULL)
  414. return OK;
  415. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  416. ("%s: MeasurementMgr is being destroyed\n", __FUNCTION__));
  417. initVec = 0xFFFF; /* release everything */
  418. measurementMgr_releaseModule(pMeasurementMgr, initVec);
  419. return OK;
  420. }
  421. /**
  422. * Sets the Measurement Mode.
  423. *
  424. * @param hMeasurementMgr A handle to the Measurement Manager module.
  425. * @param capabilities The AP capabilities.
  426. * @param pIeBuffer Pointer to the list of IEs.
  427. * @param length Length of the IE list.
  428. *
  429. * @date 16-Dec-2005
  430. */
  431. TI_STATUS measurementMgr_setMeasurementMode(TI_HANDLE hMeasurementMgr, UINT16 capabilities,
  432. UINT8 * pIeBuffer, UINT16 length)
  433. {
  434. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  435. /*
  436. * 11h Measurement is not supported in the current version.
  437. */
  438. /* if( (pMeasurementMgr->Capabilities & MEASUREMENT_CAPABILITIES_DOT11H) &&
  439. (capabilities & DOT11_SPECTRUM_MANAGEMENT) )
  440. {
  441. pMeasurementMgr->Mode = MSR_MODE_SPECTRUM_MANAGEMENT;
  442. }
  443. else
  444. {
  445. */
  446. #ifdef EXC_MODULE_INCLUDED
  447. if(pMeasurementMgr->Capabilities & MEASUREMENT_CAPABILITIES_EXC_RM)
  448. {
  449. pMeasurementMgr->Mode = MSR_MODE_EXC;
  450. }
  451. else
  452. #endif
  453. {
  454. pMeasurementMgr->Mode = MSR_MODE_NONE;
  455. }
  456. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  457. ("%s: MeasurementMgr mode changed to: %d\n", __FUNCTION__, pMeasurementMgr->Mode));
  458. return OK;
  459. }
  460. /**
  461. * Called when a frame with type measurement request is received.
  462. *
  463. * @param hMeasurementMgr A handle to the Measurement Manager module.
  464. * @param frameType The frame type.
  465. * @param dataLen The length of the frame.
  466. * @param pData A pointer to the frame's content.
  467. *
  468. * @date 16-Dec-2005
  469. */
  470. TI_STATUS measurementMgr_receiveFrameRequest(TI_HANDLE hMeasurementMgr,
  471. measurement_frameType_e frameType,
  472. INT32 dataLen,
  473. UINT8 * pData)
  474. {
  475. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  476. measurement_frameRequest_t * frame = &(pMeasurementMgr->newFrameRequest);
  477. UINT16 currentFrameToken;
  478. /* checking if measurement is enabled */
  479. if (pMeasurementMgr->Mode == MSR_MODE_NONE)
  480. return NOK;
  481. /* ignore broadcast/multicast request if unicast request is active */
  482. if (frameType != MSR_FRAME_TYPE_UNICAST && pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
  483. {
  484. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  485. ("%s: Broadcast/Multicast measurement frame has been ignored\n", __FUNCTION__));
  486. return MEASUREMENT_REQUEST_IGNORED;
  487. }
  488. /* ignore broadcast request if multicast request is active */
  489. if (frameType == MSR_FRAME_TYPE_BROADCAST && pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_MULTICAST)
  490. {
  491. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  492. ("%s: Broadcast measurement frame has been ignored\n", __FUNCTION__));
  493. return MEASUREMENT_REQUEST_IGNORED;
  494. }
  495. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  496. ("%s: Measurement frame received\n", __FUNCTION__));
  497. /* Parsing the Frame Request Header */
  498. pMeasurementMgr->parserFrameReq(hMeasurementMgr, pData, dataLen,
  499. frame);
  500. frame->frameType = frameType;
  501. /* checking if the received token frame is the same as the one that is being processed */
  502. if ((requestHandler_getFrameToken(pMeasurementMgr->hRequestH, &currentFrameToken) == OK)
  503. && (currentFrameToken == frame->hdr->dialogToken))
  504. {
  505. os_memoryZero(pMeasurementMgr->hOs, &pMeasurementMgr->newFrameRequest,
  506. sizeof(measurement_frameRequest_t));
  507. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  508. ("%s: Measurement frame token %d is identical to current frame token - ignoring frame\n", __FUNCTION__, currentFrameToken));
  509. return MEASUREMENT_REQUEST_IGNORED;
  510. }
  511. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  512. ("%s: Measurement frame token is %d\n", __FUNCTION__, frame->hdr->dialogToken));
  513. /* Frame is Received for processing */
  514. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  515. MEASUREMENTMGR_EVENT_FRAME_RECV, pMeasurementMgr);
  516. }
  517. /**
  518. * Activates the next measurement request.
  519. *
  520. * @param hMeasurementMgr A handle to the Measurement Manager module.
  521. *
  522. * @date 16-Dec-2005
  523. */
  524. TI_STATUS measurementMgr_activateNextRequest(TI_HANDLE hMeasurementMgr)
  525. {
  526. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  527. requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
  528. MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
  529. UINT8 numOfRequestsInParallel = 0;
  530. BOOL valid;
  531. UINT8 index;
  532. /* Keep note of the time we started processing the request. this will be used */
  533. /* to give the measurementSRV a time frame to perform the measurement operation */
  534. pMeasurementMgr->currentRequestStartTime = os_timeStampMs(pMeasurementMgr->hOs);
  535. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  536. ("%s: Timer started at %d, we have 20ms to begin measurement...\n", __FUNCTION__,
  537. pMeasurementMgr->currentRequestStartTime));
  538. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  539. ("%s: Looking for a valid request\n", __FUNCTION__));
  540. do
  541. {
  542. TI_STATUS status;
  543. if (numOfRequestsInParallel != 0)
  544. {
  545. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  546. ("%s: Changing activeRequestID from %d to %d, and numOfWaitingRequests from %d to %d.\n", __FUNCTION__,
  547. pRequestH->activeRequestID, pRequestH->activeRequestID + numOfRequestsInParallel, pRequestH->numOfWaitingRequests, pRequestH->numOfWaitingRequests - numOfRequestsInParallel));
  548. }
  549. pRequestH->activeRequestID += numOfRequestsInParallel;
  550. pRequestH->numOfWaitingRequests -= numOfRequestsInParallel;
  551. for (index = 0; index < MAX_NUM_REQ; index++)
  552. {
  553. pRequestArr[index] = NULL;
  554. }
  555. numOfRequestsInParallel = 0;
  556. /* Getting the next request/requests from the request handler */
  557. status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, FALSE, pRequestArr,
  558. &numOfRequestsInParallel);
  559. /* Checking if there are no waiting requests */
  560. if (status != OK)
  561. {
  562. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  563. ("%s: There are no waiting requests in the queue\n", __FUNCTION__));
  564. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  565. MEASUREMENTMGR_EVENT_SEND_REPORT, pMeasurementMgr);
  566. }
  567. /* Checking validity of request/s */
  568. valid = measurementMgr_isRequestValid(pMeasurementMgr, pRequestArr,
  569. numOfRequestsInParallel);
  570. /* Checking if the current request is Beacon Table */
  571. if( (numOfRequestsInParallel == 1) &&
  572. (pRequestArr[0]->Type == MSR_TYPE_BEACON_MEASUREMENT) &&
  573. (pRequestArr[0]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE) )
  574. {
  575. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  576. ("%s: Received Beacon Table request, building a report for it and continuing\n", __FUNCTION__));
  577. pMeasurementMgr->buildReport(hMeasurementMgr, *(pRequestArr[0]), NULL);
  578. valid = FALSE; /* In order to get the next request/s*/
  579. }
  580. } while (valid == FALSE);
  581. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  582. ("%s: Request(s) for activation:\n", __FUNCTION__));
  583. for (index = 0; index < numOfRequestsInParallel; index++)
  584. {
  585. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  586. ("%s: \n\nRequest #%d:\n Type: %d\n Measured Channel: %d (Serving Channel: %d)\n Scan Mode: %d\n Duration: %d\n\n", __FUNCTION__,
  587. index+1, pRequestArr[index]->Type, pRequestArr[index]->channelNumber,
  588. pMeasurementMgr->servingChannelID, pRequestArr[index]->ScanMode, pRequestArr[index]->DurationTime));
  589. }
  590. /* Ignore requests if traffic intensity is high */
  591. if (measurementMgr_isTrafficIntensityHigherThanThreshold(pMeasurementMgr) == TRUE)
  592. {
  593. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  594. ("%s: Traffic intensity too high, giving up...\n", __FUNCTION__));
  595. measurementMgr_rejectPendingRequests(pMeasurementMgr, MSR_REJECT_TRAFFIC_INTENSITY_TOO_HIGH);
  596. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  597. MEASUREMENTMGR_EVENT_SEND_REPORT, pMeasurementMgr);
  598. }
  599. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  600. ("%s: Request is Valid, about to start\n", __FUNCTION__));
  601. pMeasurementMgr->measuredChannelID = pRequestArr[0]->channelNumber;
  602. /* Request resource from the SCR */
  603. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  604. MEASUREMENTMGR_EVENT_REQUEST_SCR, pMeasurementMgr);
  605. }
  606. void measurementMgr_rejectPendingRequests(TI_HANDLE hMeasurementMgr, measurement_rejectReason_e rejectReason)
  607. {
  608. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  609. requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
  610. MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
  611. UINT8 numOfRequestsInParallel;
  612. /* reject all pending measurement requests */
  613. while (requestHandler_getNextReq(pMeasurementMgr->hRequestH, TRUE,
  614. pRequestArr, &numOfRequestsInParallel) == OK)
  615. {
  616. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  617. ("%s: Rejecting pending request (activeRequestID = %d)...\n", __FUNCTION__, pRequestH->activeRequestID));
  618. pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr,
  619. numOfRequestsInParallel, rejectReason);
  620. pRequestH->activeRequestID += numOfRequestsInParallel;
  621. }
  622. }
  623. /********************************************************************************/
  624. /* Callback functions Implementation. */
  625. /********************************************************************************/
  626. /**
  627. * The callback called by the MeasurementSRV module when then
  628. * measurement operation has ended.
  629. *
  630. * @param clientObj A handle to the Measurement Manager module.
  631. * @param msrReply An array of replies sent by the MeasurementSRV module,
  632. * where each reply contains the result of a single measurement request.
  633. *
  634. * @date 01-Jan-2006
  635. */
  636. void measurementMgr_MeasurementCompleteCB(TI_HANDLE clientObj, measurement_reply_t * msrReply)
  637. {
  638. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) clientObj;
  639. UINT8 index;
  640. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  641. ("%s: Building reports for measurement requests\n", __FUNCTION__));
  642. /* build a report for each measurement request/reply pair */
  643. for (index = 0; index < msrReply->numberOfTypes; index++)
  644. {
  645. pMeasurementMgr->buildReport(pMeasurementMgr, *(pMeasurementMgr->currentRequest[index]), &msrReply->msrTypes[index]);
  646. }
  647. measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  648. MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);
  649. }
  650. /**
  651. * The callback called when the SCR responds to the SCR request.
  652. *
  653. * @param hClient A handle to the Measurement Manager module.
  654. * @param requestStatus The request's status
  655. * @param pendReason The reason of a PEND status.
  656. *
  657. * @date 01-Jan-2006
  658. */
  659. void measurementMgr_scrResponseCB(TI_HANDLE hClient, scr_clientRequestStatus_e requestStatus,
  660. scr_pendReason_e pendReason )
  661. {
  662. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hClient;
  663. measurementMgrSM_Events event;
  664. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  665. ("%s: SCR callback entered\n", __FUNCTION__));
  666. /* If the SM is in a state where it waits for the CB, status of RUN */
  667. /* results in the SM asking the measurementSRV to start measurement; */
  668. /* otherwise we got an ABORT or a PEND reason worse than the one we */
  669. /* got when calling the SCR, so the SM aborts the measurement */
  670. if (pMeasurementMgr->currentState == MEASUREMENTMGR_STATE_WAITING_FOR_SCR)
  671. {
  672. if (requestStatus == SCR_CRS_RUN)
  673. {
  674. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  675. ("%s: Received SCR status RUN, running...\n", __FUNCTION__));
  676. event = MEASUREMENTMGR_EVENT_SCR_RUN;
  677. }
  678. else
  679. {
  680. if (requestStatus == SCR_CRS_PEND)
  681. {
  682. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  683. ("%s: Received SCR status PEND with reason %d, aborting...\n", __FUNCTION__, pendReason));
  684. }
  685. else
  686. {
  687. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  688. ("%s: Received SCR status ABORT/FW_RESET, aborting...\n", __FUNCTION__));
  689. }
  690. event = MEASUREMENTMGR_EVENT_ABORT;
  691. }
  692. }
  693. else
  694. {
  695. /* This can only occur if FW reset occurs or when higher priority */
  696. /* client is running in all these cases indicate ABORT event */
  697. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  698. ("%s: MeasurementMgrSM current state is %d (which isn't WAITING_FOR_SCR), aborting...\n", __FUNCTION__, pMeasurementMgr->currentState));
  699. event = MEASUREMENTMGR_EVENT_ABORT;
  700. }
  701. measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  702. event, pMeasurementMgr);
  703. }
  704. /**
  705. * The callback called by the MLME.
  706. *
  707. * @param hMeasurementMgr A handle to the Measurement Manager module.
  708. *
  709. * @date 01-Jan-2006
  710. */
  711. void measurementMgr_mlmeResultCB(TI_HANDLE hMeasurementMgr, macAddress_t * bssid, mlmeFrameInfo_t * frameInfo,
  712. Rx_attr_t * pRxAttr, UINT8 * buffer, UINT16 bufferLength)
  713. {
  714. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  715. /* check whether the packet was received while the firmware was performing a beacon measurement */
  716. BOOL receivedWhileMeasuring = ((pRxAttr->packetInfo & RX_PACKET_FLAGS_MEASURMENT) == RX_PACKET_FLAGS_MEASURMENT);
  717. if (pMeasurementMgr == NULL || pRxAttr == NULL)
  718. {
  719. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  720. ("%s: MLME callback called with NULL object\n", __FUNCTION__));
  721. return;
  722. }
  723. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  724. ("%s: MLME callback entered\n", __FUNCTION__));
  725. /* save scan results in site manager */
  726. siteMgr_updateSite(pMeasurementMgr->hSiteMgr, bssid, frameInfo, pRxAttr->channel, (radioBand_e)pRxAttr->band, receivedWhileMeasuring);
  727. if (frameInfo->subType == PROBE_RESPONSE)
  728. {
  729. siteMgr_saveProbeRespBuffer(pMeasurementMgr->hSiteMgr, bssid, buffer, bufferLength);
  730. }
  731. else if (frameInfo->subType == BEACON)
  732. {
  733. siteMgr_saveBeaconBuffer(pMeasurementMgr->hSiteMgr, bssid, buffer, bufferLength);
  734. }
  735. else
  736. {
  737. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  738. ("%s: Unknown frame subtype (%d)\n", __FUNCTION__, frameInfo->subType));
  739. }
  740. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  741. ("%s: MLME Frame: rcvWhileMeasuring = %d, Subtype = %d, MAC = %x-%x-%x-%x-%x-%x, RSSI = %d\n",
  742. __FUNCTION__, receivedWhileMeasuring, frameInfo->subType,
  743. bssid->addr[0], bssid->addr[1], bssid->addr[2],
  744. bssid->addr[3], bssid->addr[4], bssid->addr[5],
  745. pRxAttr->Rssi));
  746. }
  747. /********************************************************************************/
  748. /* Internal functions Implementation. */
  749. /********************************************************************************/
  750. /**
  751. * Releases the module's allocated objects according to the given init vector.
  752. *
  753. * @param pMeasurementMgr A handle to the Measurement Manager module.
  754. * @param initVec The init vector with a bit set for each allocated object.
  755. *
  756. * @date 01-Jan-2006
  757. */
  758. static void measurementMgr_releaseModule(measurementMgr_t * pMeasurementMgr, UINT32 initVec)
  759. {
  760. #ifdef EXC_MODULE_INCLUDED
  761. UINT32 currAC;
  762. #endif
  763. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  764. ("%s: InitVec = %d\n", __FUNCTION__, initVec));
  765. if (initVec & (1 << MEASUREMENT_ACTIVATION_DELAY_TIMER_INIT_BIT))
  766. {
  767. os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
  768. utils_nullTimerDestroy(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
  769. #ifdef EXC_MODULE_INCLUDED
  770. for (currAC = 0; currAC < MAX_NUM_OF_AC; currAC++)
  771. {
  772. if (pMeasurementMgr->pTsMetricsReportTimer[currAC] != NULL)
  773. {
  774. os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pTsMetricsReportTimer[currAC]);
  775. utils_nullTimerDestroy(pMeasurementMgr->hOs, pMeasurementMgr->pTsMetricsReportTimer[currAC]);
  776. }
  777. }
  778. #endif
  779. }
  780. if (initVec & (1 << MEASUREMENT_SM_INIT_BIT))
  781. fsm_Unload(pMeasurementMgr->hOs, pMeasurementMgr->pMeasurementMgrSm);
  782. if (initVec & (1 << MEASUREMENT_REQUEST_HANDLER_SUB_MODULE_INIT_BIT))
  783. requestHandler_destroy(pMeasurementMgr->hRequestH);
  784. if (initVec & (1 << MEASUREMENT_INIT_BIT))
  785. utils_nullMemoryFree(pMeasurementMgr->hOs, pMeasurementMgr, sizeof(measurementMgr_t));
  786. }
  787. /**
  788. * Checks whether the traffic intensity, i.e. number of packets per seconds, is higher
  789. * than the preconfigured threshold.
  790. *
  791. * @param pMeasurementMgr A handle to the Measurement Manager module.
  792. *
  793. * @return True iff the traffic intensity is high
  794. *
  795. * @date 01-Jan-2006
  796. */
  797. static BOOL measurementMgr_isTrafficIntensityHigherThanThreshold(measurementMgr_t * pMeasurementMgr)
  798. {
  799. BOOL trafficIntensityHigh = FALSE;
  800. int pcksPerSec;
  801. pcksPerSec = TrafficMonitor_GetFrameBandwidth(pMeasurementMgr->hTrafficMonitor);
  802. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  803. ("%s: pcksPerSec = %d\n", __FUNCTION__, pcksPerSec));
  804. if (pcksPerSec >= pMeasurementMgr->trafficIntensityThreshold)
  805. trafficIntensityHigh = TRUE;
  806. return trafficIntensityHigh;
  807. }
  808. /**
  809. * Checks whether the given measurement request is valid.
  810. *
  811. * @param hMeasurementMgr A handle to the Measurement Manager module.
  812. * @param pRequestArr The measurement request.
  813. * @param numOfRequest Number of type requests
  814. *
  815. * @return True iff the request is valid
  816. *
  817. * @date 01-Jan-2006
  818. */
  819. static BOOL measurementMgr_isRequestValid(TI_HANDLE hMeasurementMgr, MeasurementRequest_t *pRequestArr[],
  820. UINT8 numOfRequest)
  821. {
  822. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  823. UINT8 requestIndex;
  824. paramInfo_t param;
  825. /* Checking validity of the measured channel number */
  826. param.content.channel = pRequestArr[0]->channelNumber;
  827. param.paramType = REGULATORY_DOMAIN_IS_CHANNEL_SUPPORTED;
  828. regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, &param);
  829. if ( !param.content.bIsChannelSupprted )
  830. {
  831. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  832. ("%s: Request rejected due to invalid channel\n", __FUNCTION__));
  833. if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
  834. pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest,
  835. MSR_REJECT_INVALID_CHANNEL);
  836. return FALSE;
  837. }
  838. else
  839. {
  840. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  841. ("%s: Request channel is Valid\n", __FUNCTION__));
  842. }
  843. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  844. ("%s: Starting to check each request:\n", __FUNCTION__));
  845. /* Check Validity of each request */
  846. for (requestIndex = 0; requestIndex < numOfRequest; requestIndex++)
  847. {
  848. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  849. ("%s: Checking request #%d:\n", __FUNCTION__, requestIndex+1));
  850. /* Checking validity of the Request Type */
  851. if (pMeasurementMgr->isTypeValid(hMeasurementMgr, pRequestArr[requestIndex]->Type,
  852. pRequestArr[requestIndex]->ScanMode) == FALSE)
  853. {
  854. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  855. ("%s: Request rejected due to invalid measurement type of request #%d (type = %d)\n", __FUNCTION__, requestIndex+1, pRequestArr[requestIndex]->Type));
  856. if(pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
  857. pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest,
  858. MSR_REJECT_INVALID_MEASUREMENT_TYPE);
  859. return FALSE;
  860. }
  861. else
  862. {
  863. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  864. ("%s: Measurement type of request #%d is supported (type = %d)\n", __FUNCTION__, requestIndex+1, pRequestArr[requestIndex]->Type));
  865. }
  866. /* For measurement types different than Beacon Table */
  867. if ((pRequestArr[requestIndex]->Type != MSR_TYPE_BEACON_MEASUREMENT) ||
  868. (pRequestArr[requestIndex]->ScanMode != MSR_SCAN_MODE_BEACON_TABLE))
  869. {
  870. /* Checking Measurement request's duration only when request is on a non-serving channel */
  871. if (pMeasurementMgr->servingChannelID != pRequestArr[requestIndex]->channelNumber)
  872. {
  873. UINT8 dtimPeriod;
  874. UINT32 beaconInterval;
  875. UINT32 dtimDuration;
  876. /* Checking duration doesn't exceed given max duration */
  877. if (pRequestArr[requestIndex]->DurationTime > pMeasurementMgr->maxDurationOnNonServingChannel)
  878. {
  879. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  880. ("%s: Request #%d rejected because duration exceeds maximum duration\n", __FUNCTION__, requestIndex+1));
  881. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  882. ("%s: Duration = %d, MaxDurationOnNonServingChannel = %d\n", __FUNCTION__,
  883. pRequestArr[requestIndex]->DurationTime,
  884. pMeasurementMgr->maxDurationOnNonServingChannel));
  885. if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
  886. pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest,
  887. MSR_REJECT_DURATION_EXCEED_MAX_DURATION);
  888. return FALSE;
  889. }
  890. else
  891. {
  892. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  893. ("%s: Duration of request #%d doesn't exceed max duration\n", __FUNCTION__, requestIndex+1));
  894. }
  895. /* Checking DTIM */
  896. /* Getting the DTIM count */
  897. param.paramType = SITE_MGR_DTIM_PERIOD_PARAM;
  898. siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
  899. dtimPeriod = param.content.siteMgrDtimPeriod;
  900. /* Getting the beacon Interval */
  901. param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
  902. siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
  903. beaconInterval = param.content.beaconInterval;
  904. dtimDuration = beaconInterval * MEASUREMENT_BEACON_INTERVAL_IN_MICRO_SEC/MEASUREMENT_MSEC_IN_MICRO*dtimPeriod;
  905. if (pRequestArr[requestIndex]->DurationTime > dtimDuration)
  906. {
  907. WLAN_REPORT_WARNING(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  908. ("%s: Request rejected due to DTIM overlap of request #%d\n", __FUNCTION__, requestIndex+1));
  909. WLAN_REPORT_WARNING(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  910. ("%s: Duration = %d, DTIM Duration = %d\n", __FUNCTION__, pRequestArr[requestIndex]->DurationTime, dtimDuration));
  911. if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
  912. pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest,
  913. MSR_REJECT_DTIM_OVERLAP);
  914. return FALSE;
  915. }
  916. else
  917. {
  918. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  919. ("%s: DTIM of request #%d doesn't overlap\n", __FUNCTION__, requestIndex+1));
  920. }
  921. }
  922. }
  923. }
  924. return TRUE;
  925. }
  926. /**
  927. * The callback called when the activation delay timer has ended.
  928. *
  929. * @param Context A handle to the Measurement Manager module.
  930. *
  931. * @date 01-Jan-2006
  932. */
  933. static void measurementMgr_uponActivationDelayTimeout(TI_HANDLE Context)
  934. {
  935. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) Context;
  936. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  937. ("%s: Activation delay timeout callback entered\n", __FUNCTION__));
  938. measurementMgr_activateNextRequest(Context);
  939. }