PageRenderTime 55ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

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

http://github.com/CyanogenMod/cm-kernel
C | 1218 lines | 599 code | 340 blank | 279 comment | 40 complexity | ea1ebc77f2c2b7fd88cf46e11838e4b3 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: measurementMgrSM.c */
  38. /* PURPOSE: Measurement Manager State Machine module interface. */
  39. /* */
  40. /**************************************************************************/
  41. #include "measurementMgrSM.h"
  42. #include "measurementMgr.h"
  43. #include "802_11Defs.h"
  44. #ifdef EXC_MODULE_INCLUDED
  45. #include "excMngr.h"
  46. #include "excRMMngr.h"
  47. #endif
  48. #include "spectrumMngmntMgr.h"
  49. #include "siteMgrApi.h"
  50. #include "MacServices_api.h"
  51. #include "healthMonitor.h"
  52. #include "regulatoryDomainApi.h"
  53. #include "whalCtrl_api.h"
  54. char * measurementMgr_stateDesc[MEASUREMENTMGR_NUM_STATES] =
  55. {
  56. "STATE_IDLE",
  57. "STATE_PROCESSING_REQUEST",
  58. "STATE_WAITING_FOR_SCR",
  59. "STATE_MEASURING"
  60. };
  61. char * measurementMgr_eventDesc[MEASUREMENTMGR_NUM_EVENTS] =
  62. {
  63. "EVENT_CONNECTED",
  64. "EVENT_DISCONNECTED",
  65. "EVENT_ENABLE",
  66. "EVENT_DISABLE",
  67. "EVENT_FRAME_RECV",
  68. "EVENT_SEND_REPORT",
  69. "EVENT_REQUEST_SCR",
  70. "EVENT_SCR_WAIT",
  71. "EVENT_SCR_RUN",
  72. "EVENT_ABORT",
  73. "EVENT_COMPLETE",
  74. "EVENT_FW_RESET"
  75. };
  76. /********************************************************************************/
  77. /* MeasurementMgr SM Action Prototypes */
  78. /********************************************************************************/
  79. static TI_STATUS measurementMgrSM_acUnexpected(void * pData);
  80. static TI_STATUS measurementMgrSM_acNop(void * pData);
  81. static TI_STATUS measurementMgrSM_acConnected(void * pData);
  82. static TI_STATUS measurementMgrSM_acDisconnected_fromIdle(void * pData);
  83. static TI_STATUS measurementMgrSM_acEnable(void * pData);
  84. static TI_STATUS measurementMgrSM_acDisable_fromIdle(void * pData);
  85. static TI_STATUS measurementMgrSM_acFrameReceived_fromIdle(void * pData);
  86. static TI_STATUS measurementMgrSM_acSendReportAndCleanObj(void * pData);
  87. static TI_STATUS measurementMgrSM_acDisconnected_fromProcessingRequest(void * pData);
  88. static TI_STATUS measurementMgrSM_acDisable_fromProcessingRequest(void * pData);
  89. static TI_STATUS measurementMgrSM_acFrameReceived_fromProcessingRequest(void * pData);
  90. static TI_STATUS measurementMgrSM_acAbort_fromProcessingRequest(void * pData);
  91. static TI_STATUS measurementMgrSM_acRequestSCR(void * pData);
  92. static TI_STATUS measurementMgrSM_acDisconnected_fromWaitForSCR(void * pData);
  93. static TI_STATUS measurementMgrSM_acDisable_fromWaitForSCR(void * pData);
  94. static TI_STATUS measurementMgrSM_acFrameReceived_fromWaitForSCR(void * pData);
  95. static TI_STATUS measurementMgrSM_acAbort_fromWaitForSCR(void * pData);
  96. static TI_STATUS measurementMgrSM_acStartMeasurement(void * pData);
  97. static TI_STATUS measurementMgrSM_acDisconnected_fromMeasuring(void * pData);
  98. static TI_STATUS measurementMgrSM_acDisable_fromMeasuring(void * pData);
  99. static TI_STATUS measurementMgrSM_acFrameReceived_fromMeasuring(void * pData);
  100. static TI_STATUS measurementMgrSM_acAbort_fromMeasuring(void * pData);
  101. static TI_STATUS measurementMgrSM_acMeasurementComplete(void * pData);
  102. static TI_STATUS measurementMgrSM_acFirmwareReset(void * pData);
  103. /********************************************************************************/
  104. /* Internal Functions Prototypes */
  105. /********************************************************************************/
  106. static void measurementMgrSM_resetParams(measurementMgr_t * pMeasurementMgr);
  107. /********************************************************************************/
  108. /* MeasurementMgr SM General Use Functions */
  109. /********************************************************************************/
  110. /**
  111. * Configures the Measurement Manager State Machine.
  112. *
  113. * @param hMeasurementMgr A handle to the Measurement Manager module.
  114. *
  115. * @date 01-Jan-2006
  116. */
  117. TI_STATUS measurementMgrSM_config(TI_HANDLE hMeasurementMgr)
  118. {
  119. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  120. TI_STATUS status;
  121. /* MeasurementMgr State Machine matrix */
  122. fsm_actionCell_t measurementMgr_matrix[MEASUREMENTMGR_NUM_STATES][MEASUREMENTMGR_NUM_EVENTS] =
  123. {
  124. /* next state and actions for STATE_IDLE state */
  125. {
  126. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acConnected}, /* CONNECTED */
  127. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromIdle}, /* DISCONNECTED */
  128. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acEnable}, /* ENABLE */
  129. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromIdle}, /* DISABLE */
  130. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromIdle}, /* FRAME_RECV */
  131. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acSendReportAndCleanObj}, /* SEND_REPORT */
  132. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* REQUEST_SCR */
  133. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* SCR_WAIT */
  134. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* SCR_RUN */
  135. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* ABORT */
  136. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* COMPLETE */
  137. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected} /* FW_RESET */
  138. },
  139. /* next state and actions for STATE_PROCESSING_REQUEST state */
  140. {
  141. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}, /* CONNECTED */
  142. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromProcessingRequest}, /* DISCONNECTED */
  143. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acNop}, /* ENABLE */
  144. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromProcessingRequest}, /* DISABLE */
  145. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromProcessingRequest}, /* FRAME_RECV */
  146. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acSendReportAndCleanObj}, /* SEND_REPORT */
  147. {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acRequestSCR}, /* REQUEST_SCR */
  148. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}, /* SCR_WAIT */
  149. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}, /* SCR_RUN */
  150. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromProcessingRequest}, /* ABORT */
  151. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}, /* COMPLETE */
  152. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected} /* FW_RESET */
  153. },
  154. /* next state and actions for STATE_WAITING_FOR_SCR state */
  155. {
  156. {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}, /* CONNECTED */
  157. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromWaitForSCR}, /* DISCONNECTED */
  158. {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acNop}, /* ENABLE */
  159. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromWaitForSCR}, /* DISABLE */
  160. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromWaitForSCR}, /* FRAME_RECV */
  161. {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}, /* SEND_REPORT */
  162. {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}, /* REQUEST_SCR */
  163. {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acNop}, /* SCR_WAIT */
  164. {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acStartMeasurement}, /* SCR_RUN */
  165. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromWaitForSCR}, /* ABORT */
  166. {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}, /* COMPLETE */
  167. {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected} /* FW_RESET */
  168. },
  169. /* next state and actions for STATE_MEASURING state */
  170. {
  171. {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* CONNECTED */
  172. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromMeasuring}, /* DISCONNECTED */
  173. {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acNop}, /* ENABLE */
  174. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromMeasuring}, /* DISABLE */
  175. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromMeasuring}, /* FRAME_RECV */
  176. {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* SEND_REPORT */
  177. {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* REQUEST_SCR */
  178. {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* SCR_WAIT */
  179. {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* SCR_RUN */
  180. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromMeasuring}, /* ABORT */
  181. {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acMeasurementComplete}, /* COMPLETE */
  182. {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acFirmwareReset} /* FW_RESET */
  183. }
  184. };
  185. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  186. ("%s: Configured MeasurementMgr state machine\n", __FUNCTION__));
  187. status = fsm_Config(pMeasurementMgr->pMeasurementMgrSm,
  188. &measurementMgr_matrix[0][0],
  189. MEASUREMENTMGR_NUM_STATES,
  190. MEASUREMENTMGR_NUM_EVENTS,
  191. measurementMgrSM_event, pMeasurementMgr->hOs);
  192. return status;
  193. }
  194. /**
  195. * Raises a State Machine event in the Measurement Manager SM.
  196. *
  197. * @param currentState A point to the member holding the SM's current state.
  198. * @param event The event we want to raise.
  199. * @param hMeasurementMgr A handle to the Measurement Manager module.
  200. *
  201. * @date 05-Jan-2006
  202. */
  203. TI_STATUS measurementMgrSM_event(UINT8 * currentState, UINT8 event, TI_HANDLE hMeasurementMgr)
  204. {
  205. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
  206. TI_STATUS status;
  207. UINT8 nextState;
  208. status = fsm_GetNextState(pMeasurementMgr->pMeasurementMgrSm,
  209. *currentState, event, &nextState);
  210. if (status != OK)
  211. {
  212. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  213. ("%s: State machine error, failed getting next state\n", __FUNCTION__));
  214. return(NOK);
  215. }
  216. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  217. ("%s: <%s, %s> --> %s\n", __FUNCTION__,
  218. measurementMgr_stateDesc[*currentState],
  219. measurementMgr_eventDesc[event],
  220. measurementMgr_stateDesc[nextState]));
  221. status = fsm_Event(pMeasurementMgr->pMeasurementMgrSm,
  222. currentState, event, (void *) pMeasurementMgr);
  223. return status;
  224. }
  225. /********************************************************************************/
  226. /* MeasurementMgr SM Action Functions */
  227. /********************************************************************************/
  228. /********************************************************************************/
  229. /* IDLE State Actions */
  230. /********************************************************************************/
  231. /**
  232. * Performs the required action when the Measurement Manager module has
  233. * been advised that the station has connected to an AP.
  234. *
  235. * @date 05-Jan-2006
  236. */
  237. static TI_STATUS measurementMgrSM_acConnected(void * pData)
  238. {
  239. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  240. paramInfo_t param;
  241. #ifdef EXC_MODULE_INCLUDED
  242. iappParsingRegistrationTable_t iappParsingRegistration;
  243. #endif
  244. /* do nothing if we're already in connected mode */
  245. if (pMeasurementMgr->Connected)
  246. {
  247. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  248. ("%s: Connected flag already set\n", __FUNCTION__));
  249. return OK;
  250. }
  251. pMeasurementMgr->Connected = TRUE;
  252. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  253. ("%s: Connected flag has been set\n", __FUNCTION__));
  254. /* get the current serving channel */
  255. param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
  256. siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
  257. pMeasurementMgr->servingChannelID = param.content.siteMgrCurrentChannel;
  258. #ifdef EXC_MODULE_INCLUDED
  259. if(pMeasurementMgr->Mode == MSR_MODE_EXC)
  260. {
  261. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  262. ("%s: MeasurementMgr set to EXC mode\n", __FUNCTION__));
  263. if(pMeasurementMgr->isModuleRegistered == FALSE)
  264. {
  265. /* Registering to the excMngr */
  266. iappParsingRegistration.handler = pMeasurementMgr;
  267. iappParsingRegistration.iappParsingRegistrationProcedure = measurementMgr_excParse;
  268. if (excMngr_registerForRecvIappPacket(pMeasurementMgr->hExcMngr,
  269. iappParsingRegistration, IAPP_RADIO_MEASUREMENT) != OK)
  270. {
  271. WLAN_REPORT_WARNING(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  272. ("%s: Could not register to receive IAPP packets\n", __FUNCTION__));
  273. return NOK;
  274. }
  275. pMeasurementMgr->isModuleRegistered = TRUE;
  276. }
  277. pMeasurementMgr->parserFrameReq = measurementMgr_excParseFrameReq;
  278. pMeasurementMgr->isTypeValid = measurementMgr_excIsTypeValid;
  279. pMeasurementMgr->buildReport = measurementMgr_excBuildReport;
  280. pMeasurementMgr->buildRejectReport = measurementMgr_excBuildRejectReport;
  281. pMeasurementMgr->sendReportAndCleanObj = measurementMgr_excSendReportAndCleanObject;
  282. requestHandler_setRequestParserFunction(pMeasurementMgr->hRequestH,
  283. measurementMgr_excParseRequestIEHdr);
  284. }
  285. else
  286. #endif
  287. {
  288. if(pMeasurementMgr->Mode == MSR_MODE_SPECTRUM_MANAGEMENT)
  289. {
  290. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  291. ("%s: MeasurementMgr set to Spectrum Management mode\n", __FUNCTION__));
  292. /* NOTE: These 5 functions need to be corrected to fit the 802.11h standered */
  293. pMeasurementMgr->parserFrameReq = measurementMgr_dot11hParseFrameReq;
  294. pMeasurementMgr->isTypeValid = measurementMgr_dot11hIsTypeValid;
  295. pMeasurementMgr->buildReport = measurementMgr_dot11hBuildReport;
  296. pMeasurementMgr->buildRejectReport = measurementMgr_dot11hBuildRejectReport;
  297. pMeasurementMgr->sendReportAndCleanObj = measurementMgr_dot11hSendReportAndCleanObject;
  298. requestHandler_setRequestParserFunction(pMeasurementMgr->hRequestH,
  299. measurementMgr_dot11hParseRequestIEHdr);
  300. }
  301. }
  302. return OK;
  303. }
  304. /**
  305. * Called when the Measurement Manager has been advised that the station
  306. * has disconnected from the AP.
  307. *
  308. * @date 05-Jan-2006
  309. */
  310. static TI_STATUS measurementMgrSM_acDisconnected_fromIdle(void * pData)
  311. {
  312. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  313. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  314. ("%s: Connected flag unset\n", __FUNCTION__));
  315. pMeasurementMgr->Connected = FALSE;
  316. return OK;
  317. }
  318. /**
  319. * Called when the Measurement Manager is enabled.
  320. *
  321. * @date 05-Jan-2006
  322. */
  323. static TI_STATUS measurementMgrSM_acEnable(void * pData)
  324. {
  325. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  326. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  327. ("%s: Measurement Manager has been enabled\n", __FUNCTION__));
  328. pMeasurementMgr->Enabled = TRUE;
  329. return OK;
  330. }
  331. /**
  332. * Called when the Measurement Manager is disabled.
  333. *
  334. * @date 05-Jan-2006
  335. */
  336. static TI_STATUS measurementMgrSM_acDisable_fromIdle(void * pData)
  337. {
  338. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  339. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  340. ("%s: Measurement Manager has been disabled\n", __FUNCTION__));
  341. pMeasurementMgr->Enabled = FALSE;
  342. return OK;
  343. }
  344. /**
  345. * Called when the SM is in an idle state and we receive a new measurement frame.
  346. *
  347. * @date 05-Jan-2006
  348. */
  349. static TI_STATUS measurementMgrSM_acFrameReceived_fromIdle(void * pData)
  350. {
  351. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  352. UINT16 activationDelay;
  353. TI_STATUS status;
  354. paramInfo_t param;
  355. UINT16 tbtt;
  356. /* handle frame request only if we're connected and measurement is enabled */
  357. if (pMeasurementMgr->Connected == FALSE ||
  358. pMeasurementMgr->Enabled == FALSE)
  359. {
  360. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  361. ("%s: Frame received while SM is in disconnected/disabled state\n", __FUNCTION__));
  362. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  363. MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
  364. }
  365. /* Setting the frame Type */
  366. pMeasurementMgr->currentFrameType = pMeasurementMgr->newFrameRequest.frameType;
  367. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  368. ("%s: Frame Type = %d\n", __FUNCTION__, pMeasurementMgr->currentFrameType));
  369. /* Getting the Beacon Interval from the Site Mgr */
  370. param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
  371. status = siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
  372. if (status != OK)
  373. {
  374. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  375. ("%s: Failed to retrieve beacon interval - not connected?\n", __FUNCTION__));
  376. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  377. MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
  378. }
  379. /* converting beacon interval to msec */
  380. tbtt = (param.content.beaconInterval * 1024) / 1000; /* from TU to msec */
  381. /* Initializing Activation Delay Time */
  382. activationDelay = pMeasurementMgr->newFrameRequest.hdr->activatioDelay;
  383. activationDelay *= tbtt;
  384. /* Adding the Measurement Offset to the activation delay */
  385. activationDelay += pMeasurementMgr->newFrameRequest.hdr->measurementOffset;
  386. /* Inserting all received measurement requests into the queue */
  387. status = requestHandler_insertRequests(pMeasurementMgr->hRequestH,
  388. pMeasurementMgr->Mode,
  389. pMeasurementMgr->newFrameRequest);
  390. /* Clean New Frame Params */
  391. os_memoryZero(pMeasurementMgr->hOs, &pMeasurementMgr->newFrameRequest,
  392. sizeof(measurement_frameRequest_t));
  393. if (status != OK)
  394. {
  395. pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
  396. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  397. ("%s: Could not insert request into the queue\n", __FUNCTION__));
  398. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  399. MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
  400. }
  401. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  402. ("%s: New frame has been inserted into the queue\n", __FUNCTION__));
  403. /* If frame type isn't Unicast add to Activation Delay a random delay */
  404. if ((pMeasurementMgr->currentFrameType != MSR_FRAME_TYPE_UNICAST) && (activationDelay > 0))
  405. {
  406. activationDelay += ((os_timeStampMs(pMeasurementMgr->hOs) % MSR_ACTIVATION_DELAY_RANDOM)
  407. + MSR_ACTIVATION_DELAY_OFFSET);
  408. }
  409. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  410. ("%s: Activation Delay in ms = %d\n", __FUNCTION__, activationDelay));
  411. if (activationDelay > 0)
  412. {
  413. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  414. ("%s: Going to wait for activation delay timer callback\n", __FUNCTION__));
  415. /* Starting the Activation Delay Timer */
  416. os_timerStart(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer,
  417. activationDelay, FALSE);
  418. return OK;
  419. }
  420. else
  421. {
  422. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  423. ("%s: Activating the next request immediately without waiting for callback\n", __FUNCTION__));
  424. /* Calling to schedule the first waiting request */
  425. return measurementMgr_activateNextRequest(pData);
  426. }
  427. }
  428. /********************************************************************************/
  429. /* PROCESSING_REQUEST State Actions */
  430. /********************************************************************************/
  431. /**
  432. * Called when the station disconnects from the AP while processing
  433. * a measurement request.
  434. *
  435. * @date 05-Jan-2006
  436. */
  437. static TI_STATUS measurementMgrSM_acDisconnected_fromProcessingRequest(void * pData)
  438. {
  439. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  440. /* Stopping the activationDelay Timer */
  441. os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
  442. /* Clear Measurement fields */
  443. measurementMgrSM_resetParams(pMeasurementMgr);
  444. pMeasurementMgr->Connected = FALSE;
  445. return OK;
  446. }
  447. /**
  448. * Called when the Measurement Manager module has been disable while
  449. * processing a measurement request.
  450. *
  451. * @date 05-Jan-2006
  452. */
  453. static TI_STATUS measurementMgrSM_acDisable_fromProcessingRequest(void * pData)
  454. {
  455. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  456. /* Stopping the activationDelay Timer */
  457. os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
  458. /* Clear Measurement fields */
  459. measurementMgrSM_resetParams(pMeasurementMgr);
  460. pMeasurementMgr->Enabled = FALSE;
  461. return OK;
  462. }
  463. /**
  464. * Called when a frame has been received while we are processing another frame.
  465. * In this case the older frame is discarded and the new frame is processed.
  466. *
  467. * @date 05-Jan-2006
  468. */
  469. static TI_STATUS measurementMgrSM_acFrameReceived_fromProcessingRequest(void * pData)
  470. {
  471. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  472. /* Stopping the activationDelay Timer */
  473. os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
  474. /* Clear Measurement fields */
  475. measurementMgrSM_resetParams(pMeasurementMgr);
  476. /* Process New Frame */
  477. return measurementMgrSM_acFrameReceived_fromIdle(pData);
  478. }
  479. /**
  480. * Sends measurement reports to the AP and cleans up the module.
  481. *
  482. * @date 05-Jan-2006
  483. */
  484. static TI_STATUS measurementMgrSM_acSendReportAndCleanObj(void * pData)
  485. {
  486. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  487. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  488. ("%s: Sending pending reports and cleaning up...\n", __FUNCTION__));
  489. return pMeasurementMgr->sendReportAndCleanObj(pData);
  490. }
  491. /**
  492. * Called when for some reason we abort while processing a request.
  493. *
  494. * @date 05-Jan-2006
  495. */
  496. static TI_STATUS measurementMgrSM_acAbort_fromProcessingRequest(void * pData)
  497. {
  498. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  499. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  500. ("%s: Entered\n", __FUNCTION__));
  501. /* Stopping the activationDelay Timer */
  502. os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
  503. /* Clear Measurement fields */
  504. measurementMgrSM_resetParams(pMeasurementMgr);
  505. return OK;
  506. }
  507. /**
  508. * Called when we finished processing a request and want to request the SCR.
  509. *
  510. * @date 05-Jan-2006
  511. */
  512. static TI_STATUS measurementMgrSM_acRequestSCR(void * pData)
  513. {
  514. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  515. scr_clientRequestStatus_e scrStatus;
  516. scr_pendReason_e scrPendReason;
  517. /* Request the channel */
  518. scrStatus = scr_clientRequest(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE, &scrPendReason);
  519. if (scrStatus == SCR_CRS_RUN)
  520. {
  521. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  522. ("%s: Received RUN response from SCR\n", __FUNCTION__));
  523. /* The channel is allocated for the measurement */
  524. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  525. MEASUREMENTMGR_EVENT_SCR_RUN, pMeasurementMgr);
  526. }
  527. else if ((scrStatus == SCR_CRS_PEND) && (scrPendReason == SCR_PR_DIFFERENT_GROUP_RUNNING))
  528. {
  529. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  530. ("%s: Received PEND/DIFFGROUP response from SCR\n", __FUNCTION__));
  531. /* No need to wait for the channel allocation */
  532. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  533. MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
  534. }
  535. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  536. ("%s: Going to wait for SCR callback...\n", __FUNCTION__));
  537. /* In all other cases wait for the callback function to be called */
  538. return OK;
  539. }
  540. /********************************************************************************/
  541. /* WAIT_FOR_SCR State Actions */
  542. /********************************************************************************/
  543. /**
  544. * Called if the station disconnects from the AP while waiting for a
  545. * response from the SCR.
  546. *
  547. * @date 05-Jan-2006
  548. */
  549. static TI_STATUS measurementMgrSM_acDisconnected_fromWaitForSCR(void * pData)
  550. {
  551. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  552. /* Release the SCR */
  553. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  554. /* Clear Measurement fields */
  555. measurementMgrSM_resetParams(pMeasurementMgr);
  556. pMeasurementMgr->Connected = FALSE;
  557. return OK;
  558. }
  559. /**
  560. * Called if the Measurement Manager module is disabled while we are
  561. * waiting for a response from the SCR.
  562. *
  563. * @date 05-Jan-2006
  564. */
  565. static TI_STATUS measurementMgrSM_acDisable_fromWaitForSCR(void * pData)
  566. {
  567. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  568. /* Release the SCR */
  569. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  570. /* Clear Measurement fields */
  571. measurementMgrSM_resetParams(pMeasurementMgr);
  572. pMeasurementMgr->Enabled = FALSE;
  573. return OK;
  574. }
  575. /**
  576. * Called if a frame is received after we requested the SCR for another frame.
  577. * In this case the older frame is discarded and the new frame is processed.
  578. *
  579. * @date 05-Jan-2006
  580. */
  581. static TI_STATUS measurementMgrSM_acFrameReceived_fromWaitForSCR(void * pData)
  582. {
  583. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  584. /* Release the SCR */
  585. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  586. /* Clear Measurement fields */
  587. measurementMgrSM_resetParams(pMeasurementMgr);
  588. /* Process New Frame */
  589. return measurementMgrSM_acFrameReceived_fromIdle(pData);
  590. }
  591. /**
  592. * Called if the SCR callbacked with a response other than RUN.
  593. *
  594. * @date 05-Jan-2006
  595. */
  596. static TI_STATUS measurementMgrSM_acAbort_fromWaitForSCR(void * pData)
  597. {
  598. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  599. /* Release the SCR */
  600. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  601. /* Build a reject report */
  602. measurementMgr_rejectPendingRequests(pMeasurementMgr, MSR_REJECT_SCR_UNAVAILABLE);
  603. /* Clear Measurement fields */
  604. pMeasurementMgr->sendReportAndCleanObj(pMeasurementMgr);
  605. return OK;
  606. }
  607. /**
  608. * Called when the SCR callbacks with a RUN response or if the SCR
  609. * returned a RUN response when we requested it.
  610. *
  611. * @date 05-Jan-2006
  612. */
  613. static TI_STATUS measurementMgrSM_acStartMeasurement(void * pData)
  614. {
  615. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  616. /* Cryptic: the first struct is the requestHandler request while */
  617. /* the second one is the measurementSRV request */
  618. MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
  619. measurement_request_t request;
  620. paramInfo_t param;
  621. UINT8 numOfRequestsInParallel;
  622. UINT8 requestIndex;
  623. UINT32 timePassed;
  624. BOOL requestedBeaconMeasurement= FALSE;
  625. TI_STATUS status;
  626. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  627. ("%s: Starting Measurement operation\n", __FUNCTION__));
  628. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  629. ("%s: Suspending health monitor\n", __FUNCTION__));
  630. /* Suspend periodic health test */
  631. healthMonitor_suspendPeriodicTest(pMeasurementMgr->hHealthMonitor);
  632. request.channel = pMeasurementMgr->measuredChannelID;
  633. request.startTime = 0; /* ignored by MeasurementSRV for now - for .11k */
  634. request.numberOfTypes = 0;
  635. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  636. ("%s: Measured Channel = %d\n", __FUNCTION__, pMeasurementMgr->measuredChannelID));
  637. param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
  638. param.content.channelCapabilityReq.channelNum = pMeasurementMgr->measuredChannelID;
  639. param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
  640. if (pMeasurementMgr->measuredChannelID <= MAX_CHANNEL_IN_BAND_2_4)
  641. {
  642. request.band = RADIO_BAND_2_4_GHZ;
  643. param.content.channelCapabilityReq.band = RADIO_BAND_2_4_GHZ;
  644. }
  645. else
  646. {
  647. request.band = RADIO_BAND_5_0_GHZ;
  648. param.content.channelCapabilityReq.band = RADIO_BAND_5_0_GHZ;
  649. }
  650. regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, &param);
  651. request.txPowerDbm = param.content.channelCapabilityRet.maxTxPowerDbm;
  652. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  653. ("%s: Querying Request Handler for the next request in the queue\n", __FUNCTION__));
  654. /* Getting the next request/requests from the request handler */
  655. status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, TRUE, pRequestArr,
  656. &numOfRequestsInParallel);
  657. if (status != OK)
  658. {
  659. WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  660. ("%s: Failed getting next request from Request Handler\n", __FUNCTION__));
  661. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  662. MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);
  663. }
  664. /* Save the number of requests in parallel so that once the */
  665. /* measurement operation ends we can get rid of this amount of requests */
  666. /* from the requestHandler */
  667. pMeasurementMgr->currentNumOfRequestsInParallel = numOfRequestsInParallel;
  668. for (requestIndex = 0; requestIndex < numOfRequestsInParallel; requestIndex++)
  669. {
  670. if (pRequestArr[requestIndex]->Type == MSR_TYPE_BEACON_MEASUREMENT)
  671. {
  672. requestedBeaconMeasurement = TRUE;
  673. if (pRequestArr[requestIndex]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE)
  674. {
  675. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  676. ("%s: Beacon Table request encountered, building report now\n", __FUNCTION__));
  677. /* building Report for beacon table request */
  678. pMeasurementMgr->buildReport(pMeasurementMgr, *pRequestArr[requestIndex], NULL);
  679. continue;
  680. }
  681. }
  682. /* save the request so we can reference it when results arrive */
  683. pMeasurementMgr->currentRequest[request.numberOfTypes] = pRequestArr[requestIndex];
  684. /* add the measurement type to the request's list */
  685. request.msrTypes[request.numberOfTypes].duration = pRequestArr[requestIndex]->DurationTime;
  686. request.msrTypes[request.numberOfTypes].scanMode = pRequestArr[requestIndex]->ScanMode;
  687. request.msrTypes[request.numberOfTypes].msrType = pRequestArr[requestIndex]->Type;
  688. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  689. ("%s:\n\nMeasurement Request #%d Details: Type = %d, Duration = %d\n\n", __FUNCTION__,
  690. request.numberOfTypes+1,
  691. request.msrTypes[request.numberOfTypes].msrType,
  692. request.msrTypes[request.numberOfTypes].duration));
  693. request.numberOfTypes++;
  694. }
  695. if (requestedBeaconMeasurement == TRUE)
  696. {
  697. /* build a probe request template and send it to the HAL */
  698. whalCtrl_setTemplate_t templateStruct;
  699. probeReqTemplate_t probeReqTemplate;
  700. ssid_t broadcastSSID;
  701. /* register to MLME for Beacons/Probe Resp */
  702. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  703. ("%s: Registering at the MLME\n", __FUNCTION__));
  704. mlmeParser_registerForBeaconAndProbeResp(pMeasurementMgr->hMlme,
  705. measurementMgr_mlmeResultCB,
  706. pMeasurementMgr);
  707. templateStruct.pTemplate = (UINT8 *) &probeReqTemplate;
  708. templateStruct.templateType = PROBE_REQUEST_TEMPLATE;
  709. broadcastSSID.len = 0;
  710. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  711. ("%s: Sending probe request template...\n", __FUNCTION__));
  712. buildProbeReqTemplate(pMeasurementMgr->hSiteMgr, &templateStruct, &broadcastSSID, request.band);
  713. whalCtrl_SetTemplate(pMeasurementMgr->hHalCtrl, &templateStruct);
  714. }
  715. /* Check if the maximum time to wait for the measurement request to */
  716. /* finish has already passed */
  717. timePassed = os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime;
  718. if (timePassed > MSR_START_MAX_DELAY)
  719. {
  720. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  721. ("%s: Maximum delay to perform measurement operation has passed (%d / %d)\n", __FUNCTION__,
  722. MSR_START_MAX_DELAY, (os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime)));
  723. pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequestsInParallel, MSR_REJECT_MAX_DELAY_PASSED);
  724. return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState),
  725. MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);
  726. }
  727. /* Yalla, start measuring */
  728. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  729. ("%s: Finished preparing request. Handing over to MeasurementSRV...\n", __FUNCTION__));
  730. MacServices_measurementSRV_startMeasurement(pMeasurementMgr->hMacServices,
  731. &request,
  732. MSR_START_MAX_DELAY - timePassed,
  733. NULL, NULL,
  734. measurementMgr_MeasurementCompleteCB, pMeasurementMgr);
  735. return OK;
  736. }
  737. /********************************************************************************/
  738. /* MEASURING State Actions */
  739. /********************************************************************************/
  740. static TI_STATUS measurementMgrSM_acDisconnected_fromMeasuring(void * pData)
  741. {
  742. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  743. /* resume the self test */
  744. healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
  745. /* stop receiving from the MLME */
  746. mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
  747. /* release the SCR */
  748. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  749. /* Clear Measurement fields */
  750. measurementMgrSM_resetParams(pMeasurementMgr);
  751. pMeasurementMgr->Connected = FALSE;
  752. return OK;
  753. }
  754. static TI_STATUS measurementMgrSM_acDisable_fromMeasuring(void * pData)
  755. {
  756. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  757. /* resume the self test */
  758. healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
  759. /* stop receiving from the MLME */
  760. mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
  761. /* release the SCR */
  762. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  763. /* Clear Measurement fields */
  764. measurementMgrSM_resetParams(pMeasurementMgr);
  765. pMeasurementMgr->Enabled = FALSE;
  766. return OK;
  767. }
  768. static TI_STATUS measurementMgrSM_acFrameReceived_fromMeasuring(void * pData)
  769. {
  770. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  771. /* resume the self test */
  772. healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
  773. /* stop receiving from the MLME */
  774. mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
  775. /* release the SCR */
  776. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  777. /* Clear Measurement fields */
  778. measurementMgrSM_resetParams(pMeasurementMgr);
  779. /* Process New Frame */
  780. return measurementMgrSM_acFrameReceived_fromIdle(pData);
  781. }
  782. static TI_STATUS measurementMgrSM_acAbort_fromMeasuring(void * pData)
  783. {
  784. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  785. /* resume the self test */
  786. healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
  787. /* stop receiving from the MLME */
  788. mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
  789. /* release the SCR */
  790. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  791. /* Clear Measurement fields */
  792. measurementMgrSM_resetParams(pMeasurementMgr);
  793. return OK;
  794. }
  795. /**
  796. * Called when we finished a measurement request.
  797. *
  798. * @date 05-Jan-2006
  799. */
  800. static TI_STATUS measurementMgrSM_acMeasurementComplete(void * pData)
  801. {
  802. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  803. requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
  804. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  805. ("%s: Completing measurement operation and resuming normal behavior\n", __FUNCTION__));
  806. /* advance the activeRequestID variable to get rid of the */
  807. /* measurement requests we've already executed */
  808. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  809. ("%s: Increasing activeRequestID from %d to %d.\n", __FUNCTION__, pRequestH->activeRequestID, pRequestH->activeRequestID + pMeasurementMgr->currentNumOfRequestsInParallel));
  810. pRequestH->activeRequestID += pMeasurementMgr->currentNumOfRequestsInParallel;
  811. /* resume the self test */
  812. healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
  813. /* stop receiving from the MLME */
  814. mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
  815. /* release the SCR */
  816. scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
  817. /* Process New Frame */
  818. return measurementMgr_activateNextRequest(pData);
  819. }
  820. /**
  821. * Called when a firmware reset has been detected.
  822. *
  823. * @date 05-Jan-2006
  824. */
  825. static TI_STATUS measurementMgrSM_acFirmwareReset(void * pData)
  826. {
  827. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  828. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  829. ("%s: Firmware Reset!!\n", __FUNCTION__));
  830. /* TODO */
  831. return OK;
  832. }
  833. /********************************************************************************/
  834. /* Miscellaneous State Actions */
  835. /********************************************************************************/
  836. /**
  837. * Called when an unexpected event has been triggered.
  838. *
  839. * @date 05-Jan-2006
  840. */
  841. static TI_STATUS measurementMgrSM_acUnexpected(void * pData)
  842. {
  843. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  844. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  845. ("%s: Entered when state is %s\n", __FUNCTION__, measurementMgr_stateDesc[pMeasurementMgr->currentState]));
  846. return OK;
  847. }
  848. /**
  849. * A do nothing action.
  850. *
  851. * @date 05-Jan-2006
  852. */
  853. static TI_STATUS measurementMgrSM_acNop(void * pData)
  854. {
  855. measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
  856. WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
  857. ("%s: Entered when state is %s\n", __FUNCTION__, measurementMgr_stateDesc[pMeasurementMgr->currentState]));
  858. return OK;
  859. }
  860. /********************************************************************************/
  861. /* Internal Functions Prototypes */
  862. /********************************************************************************/
  863. static void measurementMgrSM_resetParams(measurementMgr_t *pMeasurementMgr)
  864. {
  865. /* clear the waiting requests */
  866. requestHandler_clearRequests(pMeasurementMgr->hRequestH);
  867. /* clearing reports data base */
  868. #ifdef EXC_MODULE_INCLUDED
  869. os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->excFrameReport),
  870. sizeof(RM_report_frame_t));
  871. #endif
  872. os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->dot11hFrameReport),
  873. sizeof(MeasurementReportFrame_t));
  874. pMeasurementMgr->frameLength = 0;
  875. pMeasurementMgr->nextEmptySpaceInReport = 0;
  876. pMeasurementMgr->measuredChannelID = 0;
  877. pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
  878. }