PageRenderTime 67ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrvSM.c

https://bitbucket.org/cyanogenmod/cm-kernel
C | 1148 lines | 694 code | 149 blank | 305 comment | 91 complexity | c83cadf14b21f2e70a455a8adcc2dab1 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  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. /** \file measurementSrv.c
  36. * \brief This file include the measurement SRV state machine implementation.
  37. * \author Ronen Kalish
  38. * \date 13-November-2005
  39. */
  40. #include "MeasurementSrvSM.h"
  41. #include "MeasurementSrv.h"
  42. #include "PowerSrv_API.h"
  43. #include "osApi.h"
  44. #include "report.h"
  45. #include "commonTypes.h"
  46. #include "fsm.h"
  47. #include "tnetwCommon.h"
  48. #include "paramIn.h"
  49. #include "public_commands.h"
  50. TI_STATUS actionUnexpected( TI_HANDLE hMeasurementSrv );
  51. TI_STATUS actionNop( TI_HANDLE hMeasurementSrv );
  52. /**
  53. * \author Ronen Kalish\n
  54. * \date 08-November-2005\n
  55. * \brief Initialize the measurement SRV SM.\n
  56. *
  57. * Function Scope \e Public.\n
  58. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  59. * \return OK if successful, NOK otherwise.\n
  60. */
  61. TI_STATUS measurementSRVSM_init( TI_HANDLE hMeasurementSRV )
  62. {
  63. measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  64. fsm_actionCell_t smMatrix[ MSR_SRV_NUM_OF_STATES ][ MSR_SRV_NUM_OF_EVENTS ] =
  65. {
  66. /* next state and actions for IDLE state */
  67. {
  68. {MSR_SRV_STATE_WAIT_FOR_DRIVER_MODE, measurementSRVSM_requestDriverMode}, /*"MESSURE_START_REQUEST"*/
  69. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/
  70. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/
  71. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/
  72. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/
  73. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/
  74. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/
  75. {MSR_SRV_STATE_IDLE, measurementSRVSRVSM_dummyStop} /*"MEASURE_STOP_REQUEST"*/
  76. },
  77. /* next state and actions for WAIT_FOR_DRIVER_MODE state */
  78. {
  79. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/
  80. {MSR_SRV_STATE_WAIT_FOR_MEASURE_START, measurementSRVSM_requestMeasureStart}, /*"DRIVER_MODE_SUCCESS"*/
  81. {MSR_SRV_STATE_IDLE, measurementSRVSM_DriverModeFailure}, /*"DRIVER_MODE_FAILURE"*/
  82. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/
  83. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/
  84. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/
  85. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/
  86. {MSR_SRV_STATE_IDLE, measurementSRVSM_stopFromWaitForDriverMode} /*"MEASURE_STOP_REQUEST"*/
  87. },
  88. /* next state and actions for WAIT_FOR_MEASURE_START state */
  89. {
  90. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/
  91. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/
  92. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/
  93. {MSR_SRV_STATE_MEASURE_IN_PROGRESS, measurementSRVSM_startMeasureTypes}, /*"START_SUCCESS"*/
  94. {MSR_SRV_STATE_IDLE, measurementSRVSM_measureStartFailure}, /*"START_FAILURE"*/
  95. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/
  96. {MSR_SRV_STATE_IDLE, measurementSRVSM_completeMeasure}, /*"STOP_COMPLETE"*/
  97. {MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_stopFromWaitForMeasureStart}
  98. /*"MEASURE_STOP_REQUEST"*/
  99. },
  100. /* next state and actions for MEASURE_IN_PROGRESS state */
  101. {
  102. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/
  103. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/
  104. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/
  105. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/
  106. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/
  107. {MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_requestMeasureStop}, /*"ALL_TYPES_COMPLETE"*/
  108. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/
  109. {MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_stopFromMeasureInProgress}
  110. /*"MEASURE_STOP_REQUEST"*/
  111. },
  112. /* next state and actions for WAIT_FOR_MEASURE_STOP state */
  113. {
  114. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/
  115. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/
  116. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/
  117. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/
  118. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/
  119. {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/
  120. {MSR_SRV_STATE_IDLE, measurementSRVSM_completeMeasure}, /*"STOP_COMPLETE"*/
  121. {MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSRVSM_dummyStop} /*"MEASURE_STOP_REQUEST"*/
  122. }
  123. };
  124. /* initialize current state */
  125. pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE;
  126. /* configure the state machine */
  127. return fsm_Config( pMeasurementSRV->SM, (fsm_Matrix_t)smMatrix,
  128. (UINT8)MSR_SRV_NUM_OF_STATES, (UINT8)MSR_SRV_NUM_OF_EVENTS,
  129. (fsm_eventActivation_t)measurementSRVSM_SMEvent, pMeasurementSRV->hOS );
  130. }
  131. #ifdef TI_DBG
  132. /* state descriptions, for state machine logging */
  133. static char stateDesc[ MSR_SRV_NUM_OF_STATES ][ MAX_DESC_STRING_LEN ] =
  134. {
  135. "STATE_IDLE\0",
  136. "STATE_WAIT_FOR_DRIVER_MODE\0",
  137. "STATE_WAIT_FOR_MEASURE_START\0",
  138. "STATE_MEASURE_IN_PROGRESS\0",
  139. "STATE_WAIT_FOR_MEASURE_STOP\0"
  140. };
  141. /* event descriptions, for state machine logging */
  142. static char eventDesc[ MSR_SRV_NUM_OF_EVENTS ][ MAX_DESC_STRING_LEN ] =
  143. {
  144. "EVENT_MEASURE_START_REQUEST\0",
  145. "EVENT_DRIVER_MODE_SUCCESS\0",
  146. "EVENT_DRIVER_MODE_FAILURE\0",
  147. "EVENT_START_SUCCESS\0",
  148. "EVENT_START_FAILURE\0",
  149. "EVENT_ALL_TYPES_COMPLETE\0",
  150. "EVENT_STOP_COMPLETE\0",
  151. "EVENT_STOP_REQUEST\0",
  152. };
  153. #endif /* TI_DBG */
  154. /**
  155. * \author Ronen Kalish\n
  156. * \date 08-November-2005\n
  157. * \brief Processes an event.\n
  158. *
  159. * Function Scope \e Public.\n
  160. * \param hMeasurementSrv - handle to the measurement SRV object.\n
  161. * \param currentState - the current scan SRV SM state.\n
  162. * \param event - the event to handle.\n
  163. * \return OK if successful, NOK otherwise.\n
  164. */
  165. TI_STATUS measurementSRVSM_SMEvent( TI_HANDLE hMeasurementSrv, measurements_SRVSMStates_e* currentState,
  166. measurement_SRVSMEvents_e event )
  167. {
  168. measurementSRV_t *pMeasurementSRV = (measurementSRV_t *)hMeasurementSrv;
  169. TI_STATUS status = OK;
  170. UINT8 nextState;
  171. /* obtain the next state */
  172. status = fsm_GetNextState( pMeasurementSRV->SM, (UINT8)*currentState, (UINT8)event, &nextState );
  173. if ( status != OK )
  174. {
  175. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  176. ("%s: State machine error, failed getting next state\n", __FUNCTION__) );
  177. return NOK;
  178. }
  179. #ifdef TI_DBG
  180. /* report the move */
  181. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  182. ("%s: <%s, %s> --> %s\n", __FUNCTION__,
  183. stateDesc[(UINT8)*currentState],
  184. eventDesc[(UINT8)event],
  185. stateDesc[nextState]) );
  186. #endif
  187. /* move */
  188. return fsm_Event( pMeasurementSRV->SM, (UINT8*)currentState, (UINT8)event, hMeasurementSrv );
  189. }
  190. /**
  191. * \author Ronen Kalish\n
  192. * \date 08-November-2005\n
  193. * \brief Handle a MEASURE_START_REQUEST event by requesting driver mode.\n
  194. *
  195. * Function Scope \e Public.\n
  196. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  197. * \return always OK.\n
  198. */
  199. TI_STATUS measurementSRVSM_requestDriverMode( TI_HANDLE hMeasurementSRV )
  200. {
  201. measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  202. TI_STATUS PSStatus;
  203. whalParamInfo_t paramInfo;
  204. /* get the current channel */
  205. paramInfo.paramType = HAL_CTRL_CURRENT_CHANNEL;
  206. whalCtrl_GetParam( pMeasurementSRV->hHalCtrl, &paramInfo );
  207. /* check if the request is on the serving channel */
  208. if ( paramInfo.content.halCtrlCurrentChannel == pMeasurementSRV->msrRequest.channel )
  209. {
  210. /* Switch Power Save SRV to driver mode w/o changing power save mode*/
  211. PSStatus = powerSrv_ReservePS( pMeasurementSRV->hPowerSaveSRV, POWER_SAVE_KEEP_CURRENT,
  212. TRUE, hMeasurementSRV, MacServices_measurementSRV_powerSaveCB );
  213. }
  214. else
  215. {
  216. /* Switch Power Save SRV to driver mode with PS mode */
  217. PSStatus = powerSrv_ReservePS( pMeasurementSRV->hPowerSaveSRV, POWER_SAVE_ON,
  218. TRUE, hMeasurementSRV, MacServices_measurementSRV_powerSaveCB );
  219. }
  220. switch (PSStatus)
  221. {
  222. case POWER_SAVE_802_11_IS_CURRENT:
  223. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  224. ("%s: Driver mode entered successfully\n",__FUNCTION__) );
  225. /* send a power save success event */
  226. return measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
  227. MSR_SRV_EVENT_DRIVER_MODE_SUCCESS );
  228. /* break; */
  229. case PENDING:
  230. case OK:
  231. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  232. ("%s: Driver mode pending\n", __FUNCTION__) );
  233. break;
  234. default: /* Error */
  235. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  236. ("%s: Error %d when requesting driver mode\n",__FUNCTION__,PSStatus) );
  237. /* Set the return status to NOK */
  238. pMeasurementSRV->returnStatus = PSStatus;
  239. /* send a power save failure event */
  240. measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
  241. MSR_SRV_EVENT_DRIVER_MODE_FAILURE );
  242. break;
  243. }
  244. return OK;
  245. }
  246. /**
  247. * \author Ronen Kalish\n
  248. * \date 08-November-2005\n
  249. * \brief Handle a DRIVER_MODE_SUCCESS event by sending start measure command to the FW.\n
  250. *
  251. * Function Scope \e Public.\n
  252. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  253. * \return always OK.\n
  254. */
  255. TI_STATUS measurementSRVSM_requestMeasureStart( TI_HANDLE hMeasurementSRV )
  256. {
  257. measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  258. whalCtrl_MeasurementParameters_t pMeasurementCmd;
  259. TI_STATUS status;
  260. UINT32 currentTime = os_timeStampMs( pMeasurementSRV->hOS );
  261. /* check if request time has expired (note: timer wrap-around is also handled)*/
  262. if ( (pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs)
  263. < currentTime )
  264. {
  265. int i;
  266. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  267. ("%s: request time has expired, request expiry time:%d, current time:%d\n",
  268. __FUNCTION__,
  269. pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs,
  270. currentTime) );
  271. /* mark that all measurement types has failed */
  272. for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
  273. {
  274. pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
  275. }
  276. /* send a measurement complete event */
  277. measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
  278. MSR_SRV_EVENT_STOP_COMPLETE );
  279. return OK;
  280. }
  281. pMeasurementCmd.channel = pMeasurementSRV->msrRequest.channel;
  282. pMeasurementCmd.band = pMeasurementSRV->msrRequest.band;
  283. pMeasurementCmd.duration = 0; /* Infinite */
  284. if ( measurementSRVIsBeaconMeasureIncluded( hMeasurementSRV ) )
  285. { /* Beacon Measurement is one of the types */
  286. /* get the current channel */
  287. whalParamInfo_t paramInfo;
  288. paramInfo.paramType = HAL_CTRL_CURRENT_CHANNEL;
  289. whalCtrl_GetParam( pMeasurementSRV->hHalCtrl, &paramInfo );
  290. pMeasurementCmd.ConfigOptions = RX_CONFIG_OPTION_FOR_MEASUREMENT;
  291. /* check if the request is on the serving channel */
  292. if ( paramInfo.content.halCtrlCurrentChannel == pMeasurementSRV->msrRequest.channel )
  293. {
  294. /* Set the RX Filter to the join one, so that any packets will
  295. be received on the serving channel - beacons and probe requests for
  296. the measurmenet, and also data (for normal operation) */
  297. pMeasurementCmd.FilterOptions = RX_FILTER_OPTION_JOIN;
  298. }
  299. else
  300. {
  301. /* not on the serving channle - only beacons and rpobe responses are required */
  302. pMeasurementCmd.FilterOptions = RX_FILTER_OPTION_DEF_PRSP_BCN;
  303. }
  304. }
  305. else
  306. { /* No beacon measurement - use the current RX Filter */
  307. pMeasurementCmd.ConfigOptions = 0xffffffff;
  308. pMeasurementCmd.FilterOptions = 0xffffffff;
  309. }
  310. /* Send start measurement command */
  311. status = (TI_STATUS)whalCtrl_measurementCmd( pMeasurementSRV->hHalCtrl, &pMeasurementCmd,
  312. (void *)measurementSRVSM_requestMeasureStartResponseCB,
  313. pMeasurementSRV );
  314. if ( OK != status )
  315. {
  316. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  317. ("%s: Failed to send measurement start command, statud=%d,\n",
  318. __FUNCTION__, status) );
  319. /* keep the faulty return status */
  320. pMeasurementSRV->returnStatus = status;
  321. /* send a measurement start fail event */
  322. return measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
  323. MSR_SRV_EVENT_START_FAILURE );
  324. }
  325. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  326. ("%s: measure start command sent. Params:\n channel=%d, band=%d, duration=%d, \n configOptions=0x%x, filterOptions=0x%x, status=%d, \n",
  327. __FUNCTION__,
  328. pMeasurementCmd.channel,
  329. pMeasurementCmd.band,
  330. pMeasurementCmd.duration,
  331. pMeasurementCmd.ConfigOptions,
  332. pMeasurementCmd.FilterOptions,
  333. status) );
  334. /* start the FW guard timer */
  335. pMeasurementSRV->bStartStopTimerRunning = TRUE;
  336. os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer, MSR_FW_GUARD_TIME, FALSE );
  337. return OK;
  338. }
  339. /**
  340. * \author Ronen Kalish\n
  341. * \date 08-November-2005\n
  342. * \brief Handle a START_SUCCESS event by starting different measure types and setting timers.\n
  343. *
  344. * Function Scope \e Public.\n
  345. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  346. * \return always OK.\n
  347. */
  348. TI_STATUS measurementSRVSM_startMeasureTypes( TI_HANDLE hMeasurementSRV )
  349. {
  350. measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  351. UINT8 requestIndex, rangeIndex;
  352. INT8 rangeUpperBound;
  353. whalParamInfo_t whalParam;
  354. TI_STATUS status;
  355. whalCtrl_noiseHistogram_t pNoiseHistParams;
  356. whalCtrl_ApDiscoveryParameters_t pApDiscoveryParams;
  357. UINT32 currentTime = os_timeStampMs( pMeasurementSRV->hOS );
  358. /* check if request time has expired (note: timer wrap-around is also handled)*/
  359. if ( (pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs)
  360. < currentTime )
  361. {
  362. int i;
  363. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  364. ("%s: request time has expired, request expiry time:%d, current time:%d\n",
  365. __FUNCTION__,
  366. pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs,
  367. currentTime) );
  368. /* mark that all measurement types has failed */
  369. for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
  370. {
  371. pMeasurementSRV->msrReply.msrTypes[ i ].status = MSR_REJECT_MAX_DELAY_PASSED;
  372. }
  373. /* send a measurement complete event */
  374. measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
  375. MSR_SRV_EVENT_ALL_TYPES_COMPLETE );
  376. return OK;
  377. }
  378. /* Going over all request types that should be executed in parallel
  379. to start their timers and execute the measurement */
  380. for ( requestIndex = 0; requestIndex < pMeasurementSRV->msrRequest.numberOfTypes ; requestIndex++ )
  381. {
  382. switch (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType)
  383. {
  384. case MSR_TYPE_CCA_LOAD_MEASUREMENT:
  385. /* Clearing the Medium Occupancy Register */
  386. whalParam.paramType = HAL_CTRL_MEDIUM_OCCUPANCY_PARAM;
  387. whalParam.content.interogateCmdCBParams.CB_Func = (void *)MacServices_measurementSRV_dummyChannelLoadParamCB;
  388. whalParam.content.interogateCmdCBParams.CB_handle = hMeasurementSRV;
  389. whalParam.content.interogateCmdCBParams.CB_buf =
  390. (UINT8*)(&(pMeasurementSRV->mediumOccupancyResults));
  391. status = whalCtrl_GetParam( pMeasurementSRV->hHalCtrl, &whalParam );
  392. if( OK == status )
  393. {
  394. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  395. ("%s: Medium Usage has been nullified, starting timer.\n", __FUNCTION__) );
  396. /* Start Timer */
  397. os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ requestIndex ],
  398. pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration, FALSE );
  399. pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TRUE;
  400. }
  401. else
  402. {
  403. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  404. ("%s: whalCtrl_GetParam (for channel load) returned status %d\n", __FUNCTION__, status) );
  405. }
  406. break;
  407. case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT:
  408. /* Set Noise Histogram Cmd Params */
  409. pNoiseHistParams.cmd = START_NOISE_HIST;
  410. pNoiseHistParams.sampleInterval = DEF_SAMPLE_INTERVAL;
  411. os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[0]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES );
  412. /* Set Ranges */
  413. /* (-87) - First Range's Upper Bound */
  414. rangeUpperBound = -87;
  415. /* Previously we converted from RxLevel to dBm - now this isn't necessary */
  416. /* rangeUpperBound = whalCtrl_convertRSSIToRxLevel( pMeasurementSRV->hHalCtrl, -87); */
  417. for(rangeIndex = 0; rangeIndex < MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES -1; rangeIndex++)
  418. {
  419. if(rangeUpperBound > 0)
  420. {
  421. pNoiseHistParams.ranges[rangeIndex] = 0;
  422. }
  423. else
  424. {
  425. pNoiseHistParams.ranges[rangeIndex] = rangeUpperBound;
  426. }
  427. rangeUpperBound += 5;
  428. }
  429. pNoiseHistParams.ranges[rangeIndex] = 0xFE;
  430. /* Print for Debug */
  431. WLAN_REPORT_INFORMATION(pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  432. ("%s:Noise histogram Measurement Ranges:\n%d %d %d %d %d %d %d %d\n", __FUNCTION__,
  433. (INT8) pNoiseHistParams.ranges[0], (INT8) pNoiseHistParams.ranges[1],
  434. (INT8) pNoiseHistParams.ranges[2], (INT8) pNoiseHistParams.ranges[3],
  435. (INT8) pNoiseHistParams.ranges[4], (INT8) pNoiseHistParams.ranges[5],
  436. (INT8) pNoiseHistParams.ranges[6], (INT8) pNoiseHistParams.ranges[7]));
  437. /* Send a Start command to the FW */
  438. status = (TI_STATUS)whalCtrl_NoiseHistogramCmd( pMeasurementSRV->hHalCtrl, &pNoiseHistParams );
  439. if ( OK == status )
  440. {
  441. /* Print for Debug */
  442. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  443. ("%s: Sent noise histogram command. Starting timer\n",
  444. __FUNCTION__) );
  445. /* Start Timer */
  446. os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ requestIndex ],
  447. pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration, FALSE );
  448. pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TRUE;
  449. }
  450. else
  451. {
  452. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  453. ("%s: whalCtrl_NoiseHistogramCmd returned status %d\n", __FUNCTION__, status) );
  454. }
  455. break;
  456. case MSR_TYPE_BEACON_MEASUREMENT:
  457. /* set all parameters in the AP discovery command */
  458. pApDiscoveryParams.scanDuration = pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration * 1000; /* TODO change this to an infinite value (was 0) */
  459. pApDiscoveryParams.numOfProbRqst = 1;
  460. pApDiscoveryParams.txdRateSet = HW_BIT_RATE_1MBPS;
  461. pApDiscoveryParams.ConfigOptions = RX_CONFIG_OPTION_FOR_MEASUREMENT;
  462. pApDiscoveryParams.FilterOptions = RX_FILTER_OPTION_DEF_PRSP_BCN;
  463. pApDiscoveryParams.txPowerDbm = pMeasurementSRV->msrRequest.txPowerDbm;
  464. pApDiscoveryParams.scanOptions = SCAN_ACTIVE; /* both scan type and band are 0 for active and */
  465. /* 2.4 GHz, respectively, but 2.4 is not defined */
  466. /* band and scan mode go into the scan option field */
  467. if ( RADIO_BAND_5_0_GHZ == pMeasurementSRV->msrRequest.band )
  468. {
  469. pApDiscoveryParams.scanOptions |= SCAN_5GHZ_BAND;
  470. }
  471. if ( MSR_SCAN_MODE_PASSIVE == pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].scanMode )
  472. {
  473. pApDiscoveryParams.scanOptions |= SCAN_PASSIVE;
  474. }
  475. /* Send AP Discovery command */
  476. status = (TI_STATUS)whalCtrl_ApDiscoveryCmd( pMeasurementSRV->hHalCtrl, &pApDiscoveryParams );
  477. if ( OK == status )
  478. {
  479. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  480. ("%s: AP discovery command sent. Params:\n scanDuration=%d, scanOptions=%d,"
  481. "numOfProbRqst=%d, txdRateSet=%d, txPowerDbm=%d, configOptions=%d, filterOptions=%d\n"
  482. "Starting timer...\n",
  483. __FUNCTION__,
  484. pApDiscoveryParams.scanDuration, pApDiscoveryParams.scanOptions,
  485. pApDiscoveryParams.numOfProbRqst, pApDiscoveryParams.txdRateSet,
  486. pApDiscoveryParams.txPowerDbm, pApDiscoveryParams.ConfigOptions,
  487. pApDiscoveryParams.FilterOptions) );
  488. /* Start Timer */
  489. os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ requestIndex ],
  490. pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration, FALSE);
  491. pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TRUE;
  492. }
  493. else
  494. {
  495. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  496. ("%s: whalCtrl_ApDiscoveryCmd returned status %d\n", __FUNCTION__, status) );
  497. }
  498. break;
  499. case MSR_TYPE_BASIC_MEASUREMENT: /* not supported in current implemntation */
  500. case MSR_TYPE_FRAME_MEASUREMENT: /* not supported in current implemntation */
  501. default:
  502. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  503. ("%s: Measurement type %d is not supported\n",
  504. __FUNCTION__, pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType) );
  505. break;
  506. }
  507. }
  508. /* if no measurement types are running, sen al types complete event.
  509. This can happen if all types failed to start */
  510. if ( TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV ) )
  511. {
  512. /* send the event */
  513. measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
  514. MSR_SRV_EVENT_ALL_TYPES_COMPLETE );
  515. }
  516. return OK;
  517. }
  518. /**
  519. * \author Ronen Kalish\n
  520. * \date 08-November-2005\n
  521. * \brief Handle an ALL_TYPE_COMPLETE event by sending a stop measure command to the FW.\n
  522. *
  523. * Function Scope \e Public.\n
  524. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  525. * \return always OK.\n
  526. */
  527. TI_STATUS measurementSRVSM_requestMeasureStop( TI_HANDLE hMeasurementSRV )
  528. {
  529. measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  530. TI_STATUS status;
  531. /* since this function may also be called when stop is requested and start complete event
  532. has not yet been received from the FW, we may need to stop the FW guard timer */
  533. if ( TRUE == pMeasurementSRV->bStartStopTimerRunning )
  534. {
  535. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, ("***** STOP TIMER 6 *****\n") );
  536. os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
  537. pMeasurementSRV->bStartStopTimerRunning = FALSE;
  538. }
  539. /* Send Measurement Stop command to the FW */
  540. status = (TI_STATUS)whalCtrl_measurementStop( pMeasurementSRV->hHalCtrl,
  541. (void *) pMeasurementSRV->commandResponseCBFunc,
  542. pMeasurementSRV->commandResponseCBObj );
  543. pMeasurementSRV->commandResponseCBFunc = NULL;
  544. pMeasurementSRV->commandResponseCBObj = NULL;
  545. if ( OK != status )
  546. {
  547. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  548. ("%s: Failed to send measurement stop command, statud=%d,\n",
  549. __FUNCTION__, status) );
  550. /* send a measurement complete event - since it can't be stopped */
  551. measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_STOP_COMPLETE );
  552. return OK;
  553. }
  554. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  555. ("%s: measure stop command sent.\n", __FUNCTION__) );
  556. /* start the FW guard timer */
  557. pMeasurementSRV->bStartStopTimerRunning = TRUE;
  558. os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer, MSR_FW_GUARD_TIME, FALSE );
  559. return OK;
  560. }
  561. /**
  562. * \author Ronen Kalish\n
  563. * \date 08-November-2005\n
  564. * \brief Handle a STOP_COMPLETE event by exiting driver mode and calling the complete CB.\n
  565. *
  566. * Function Scope \e Public.\n
  567. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  568. * \return always OK.\n
  569. */
  570. TI_STATUS measurementSRVSM_completeMeasure( TI_HANDLE hMeasurementSRV )
  571. {
  572. measurementSRV_t *pMeasurementSRV = (measurementSRV_t *)hMeasurementSRV;
  573. /* Switch Power Save SRV back to user mode */
  574. powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL );
  575. /* if the response CB is still pending, call it (when requestExpiryTimeStamp was reached) */
  576. if ( NULL != pMeasurementSRV->commandResponseCBFunc )
  577. {
  578. pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, OK );
  579. }
  580. /* call the complete CB */
  581. if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
  582. {
  583. pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
  584. &(pMeasurementSRV->msrReply) );
  585. }
  586. return OK;
  587. }
  588. /**
  589. * \author Ronen Kalish\n
  590. * \date 08-November-2005\n
  591. * \brief Handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE state by exiting driver mode.
  592. *
  593. * Function Scope \e Public.\n
  594. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  595. * \return always OK.\n
  596. */
  597. TI_STATUS measurementSRVSM_stopFromWaitForDriverMode( TI_HANDLE hMeasurementSRV )
  598. {
  599. measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  600. /* Switch Power Save SRV back to user mode */
  601. powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL );
  602. /* if we are not running within a stop request context (shouldn't happen), call the CBs */
  603. if ( FALSE == pMeasurementSRV->bInRequest )
  604. {
  605. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  606. ("%s: stop from wait for driver mode: not within a request context?!? \n", __FUNCTION__) );
  607. /* call the response CB - this shouldn't happen, as only GWSI has response CB, and it shouldn't call
  608. stop before driver */
  609. if ( NULL != pMeasurementSRV->commandResponseCBFunc )
  610. {
  611. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  612. ("%s: stop from wait for driver mode: command response CB is not NULL?!? \n", __FUNCTION__) );
  613. pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, OK );
  614. pMeasurementSRV->commandResponseCBFunc = NULL;
  615. pMeasurementSRV->commandResponseCBObj = NULL;
  616. }
  617. /* call the complete CB */
  618. if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
  619. {
  620. /* mark that all types has failed */
  621. int i;
  622. for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
  623. {
  624. pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
  625. }
  626. /* call the complete CB */
  627. pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
  628. &(pMeasurementSRV->msrReply) );
  629. }
  630. else
  631. {
  632. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  633. ("%s: stop from wait for driver mode and response CB is NULL!!!\n",
  634. __FUNCTION__) );
  635. }
  636. }
  637. /* we are within a stop request context */
  638. else
  639. {
  640. /* if the command response Cb is valid, send a measure stop command to the FW -
  641. although it is not necessary, we need it to get a different context for the command response.
  642. This shouldn't happen, as only GWSI has command response, and it shouldn't call stop measure
  643. before it got the commadn response for start measure */
  644. if ( NULL != pMeasurementSRV->commandResponseCBFunc )
  645. {
  646. /* shouldn't happen - a command response is valid (GWSI) and stop measure called
  647. before measure start response was received (driver) */
  648. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  649. ("%s: stop from wait for driver mode - within request context and command response is not NULL?!?\n", __FUNCTION__) );
  650. whalCtrl_measurementStop( pMeasurementSRV->hHalCtrl, (void *)pMeasurementSRV->commandResponseCBFunc,
  651. pMeasurementSRV->commandResponseCBObj );
  652. pMeasurementSRV->commandResponseCBFunc = NULL;
  653. pMeasurementSRV->commandResponseCBObj = NULL;
  654. }
  655. if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
  656. {
  657. /* Note: this is being called from request context, but there's npthing else that can be done */
  658. /* mark that all types has failed */
  659. int i;
  660. for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
  661. {
  662. pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
  663. }
  664. /* call the complete CB */
  665. pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
  666. &(pMeasurementSRV->msrReply) );
  667. }
  668. }
  669. return OK;
  670. }
  671. /**
  672. * \author Ronen Kalish\n
  673. * \date 27-November-2005\n
  674. * \brief handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE by marking negative result status
  675. * \brief and calling the ordinary stop function
  676. *
  677. * Function Scope \e Public.\n
  678. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  679. * \return always OK.\n
  680. */
  681. TI_STATUS measurementSRVSM_stopFromWaitForMeasureStart( TI_HANDLE hMeasurementSRV )
  682. {
  683. measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  684. int i;
  685. /* mark that all types has failed */
  686. for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
  687. {
  688. pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
  689. }
  690. /* call the ordinary stop function (will send a measure stop command to FW) */
  691. measurementSRVSM_requestMeasureStop( hMeasurementSRV );
  692. return OK;
  693. }
  694. /**
  695. * \author Ronen Kalish\n
  696. * \date 08-November-2005\n
  697. * \brief handle a STOP_REQUEST event when in MEASURE_IN_PROGRESS by stopping all measure types and
  698. * \brief requesting measure stop from the FW.\n
  699. *
  700. * Function Scope \e Public.\n
  701. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  702. * \return always OK.\n
  703. */
  704. TI_STATUS measurementSRVSM_stopFromMeasureInProgress( TI_HANDLE hMeasurementSRV )
  705. {
  706. measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  707. whalCtrl_noiseHistogram_t pNoiseHistParams;
  708. TI_STATUS status;
  709. int i;
  710. /* stop all running measure types */
  711. for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
  712. {
  713. if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
  714. {
  715. /* stop timer */
  716. os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
  717. pMeasurementSRV->bRequestTimerRunning[ i ] = FALSE;
  718. /* if necessary, stop measurement type */
  719. switch ( pMeasurementSRV->msrRequest.msrTypes[ i ].msrType )
  720. {
  721. case MSR_TYPE_BEACON_MEASUREMENT:
  722. /* send stop AP discovery command */
  723. status = (TI_STATUS)whalCtrl_ApDiscoveryStop( pMeasurementSRV->hHalCtrl );
  724. if ( OK != status )
  725. {
  726. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  727. ("%s: whalCtrl_ApDiscoveryStop returned status %d\n", __FUNCTION__, status) );
  728. }
  729. break;
  730. case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT:
  731. /* Set Noise Histogram Cmd Params */
  732. pNoiseHistParams.cmd = STOP_NOISE_HIST;
  733. pNoiseHistParams.sampleInterval = 0;
  734. os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[ 0 ]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES );
  735. /* Send a Stop command to the FW */
  736. status = (TI_STATUS)whalCtrl_NoiseHistogramCmd( pMeasurementSRV->hHalCtrl, &pNoiseHistParams );
  737. if ( OK != status )
  738. {
  739. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  740. ("%s: whalCtrl_NoiseHistogramCmd returned status %d\n", __FUNCTION__, status) );
  741. }
  742. break;
  743. /* These are just to avoid compilation warnings, nothing is actualy done here! */
  744. case MSR_TYPE_BASIC_MEASUREMENT:
  745. case MSR_TYPE_CCA_LOAD_MEASUREMENT:
  746. case MSR_TYPE_FRAME_MEASUREMENT:
  747. case MSR_TYPE_MAX_NUM_OF_MEASURE_TYPES:
  748. default:
  749. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  750. ("%s: unsupported measurement type: %d\n",
  751. __FUNCTION__,
  752. pMeasurementSRV->msrRequest.msrTypes[ i ].msrType) );
  753. break;
  754. }
  755. /* mark that measurement has failed */
  756. pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
  757. }
  758. }
  759. /* Send Measurement Stop command to the FW */
  760. status = (TI_STATUS)whalCtrl_measurementStop( pMeasurementSRV->hHalCtrl,
  761. (void *)pMeasurementSRV->commandResponseCBFunc,
  762. pMeasurementSRV->commandResponseCBObj );
  763. pMeasurementSRV->commandResponseCBFunc = NULL;
  764. pMeasurementSRV->commandResponseCBObj = NULL;
  765. if ( OK != status )
  766. {
  767. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  768. ("%s: Failed to send measurement stop command, statud=%d,\n",
  769. __FUNCTION__, status) );
  770. /* send a measurement complete event - since it can't be stopped */
  771. measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
  772. MSR_SRV_EVENT_STOP_COMPLETE );
  773. return OK;
  774. }
  775. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  776. ("%s: measure stop command sent.\n") );
  777. /* start the FW guard timer */
  778. pMeasurementSRV->bStartStopTimerRunning = TRUE;
  779. os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer, MSR_FW_GUARD_TIME, FALSE );
  780. return OK;
  781. }
  782. /**
  783. * \author Ronen Kalish\n
  784. * \date 08-November-2005\n
  785. * \brief handle a DRIVER_MODE_FAILURE event by calling the response and complete CBs.\n
  786. *
  787. * Function Scope \e Public.\n
  788. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  789. * \return always OK.\n
  790. */
  791. TI_STATUS measurementSRVSM_DriverModeFailure( TI_HANDLE hMeasurementSRV )
  792. {
  793. measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  794. /* this function can be called from within a request (when the power save SRV returned an immediate error),
  795. or in a different context, when power save entry failed. The latter is a valid status, whereas the former
  796. indicates a severe error. However, as there is nothing to do with the former (other than debug it), the same
  797. failure indication is used for both of them, which will make the upper layer (Palau driver or TI measurement
  798. manager) to return to idle state. Still, for the former the error is returned as the return status from the
  799. measurement start API call whereas for the latter the error is indicated both by the command response and
  800. measurement complete CBs status */
  801. /* if we are running within a request context, don't call the CBs! The startMeasurement function
  802. will return an invalid status instead */
  803. if ( FALSE == pMeasurementSRV->bInRequest )
  804. {
  805. /* if a response CB is available (GWSI) call it */
  806. if ( NULL != pMeasurementSRV->commandResponseCBFunc )
  807. {
  808. pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, NOK );
  809. }
  810. /* if a complete CB is available (both GWSI and TI driver), call it */
  811. if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
  812. {
  813. /* mark that all types has failed */
  814. int i;
  815. for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
  816. {
  817. pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
  818. }
  819. /* call the complete CB */
  820. pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
  821. &(pMeasurementSRV->msrReply) );
  822. }
  823. else
  824. {
  825. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  826. ("%s: driver mode failure and complete CB is NULL!!!\n",
  827. __FUNCTION__) );
  828. }
  829. }
  830. return OK;
  831. }
  832. /**
  833. * \author Ronen Kalish\n
  834. * \date 08-November-2005\n
  835. * \brief handle a START_FAILURE event by exiting driver mode and calling the complete CB.\n
  836. *
  837. * Function Scope \e Public.\n
  838. * \param hMeasurementSrv - handle to the Measurement SRV object.\n
  839. * \return always OK.\n
  840. */
  841. TI_STATUS measurementSRVSM_measureStartFailure( TI_HANDLE hMeasurementSRV )
  842. {
  843. measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  844. /* This function can be called from within a request context (if the driver mode entry process
  845. was immediate), or from the driver mode CB context. Regardless of teh context in which it runs,
  846. The error indicates that something is wrong in the HAL. There is no way to solve this (other than debug it).
  847. The error is either indicating by the measurement start API return status (if still in the request context),
  848. or by calling the response (if available, only in GWSI) and complete CBs with invalid status */
  849. /* Switch Power save SRV back to user mode */
  850. powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL );
  851. /* if we are running within a request context, don't call the CB! The startMeasurement function
  852. will return an invalid status instead */
  853. if ( FALSE == pMeasurementSRV->bInRequest )
  854. {
  855. /* if a response CB is available (GWSI) call it */
  856. if ( NULL != pMeasurementSRV->commandResponseCBFunc )
  857. {
  858. pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, NOK );
  859. }
  860. /* if a complete CB is available (both GWSI and TI driver), call it */
  861. if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
  862. {
  863. /* mark that all types has failed */
  864. int i;
  865. for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
  866. {
  867. pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
  868. }
  869. /* call the complete CB */
  870. pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
  871. &(pMeasurementSRV->msrReply) );
  872. }
  873. else
  874. {
  875. WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  876. ("%s: Start measurement failure and response and complete CBs are NULL!!!\n",
  877. __FUNCTION__) );
  878. }
  879. }
  880. return OK;
  881. }
  882. void measurementSRVSM_requestMeasureStartResponseCB(TI_HANDLE hMeasurementSRV, UINT16 uMboxStatus)
  883. {
  884. measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
  885. int i;
  886. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  887. ("%s: FW has responded with CMD_STATUS = %d\n",
  888. __FUNCTION__, uMboxStatus) );
  889. if (uMboxStatus == OK)
  890. {
  891. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  892. ("%s: FW has responded with CMD_STATUS_SUCCESS!\n",
  893. __FUNCTION__) );
  894. if ( NULL != pMeasurementSRV->commandResponseCBFunc )
  895. {
  896. pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, OK );
  897. }
  898. }
  899. else
  900. {
  901. if (uMboxStatus == SG_REJECT_MEAS_SG_ACTIVE)
  902. {
  903. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  904. ("%s: FW has responded with CMD_STATUS_REJECT_MEAS_SG_ACTIVE!\n",
  905. __FUNCTION__) );
  906. }
  907. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
  908. ("%s: FW has responded with CMD_STATUS NOK!!!\n",
  909. __FUNCTION__) );
  910. /* if a timer is running, stop it */
  911. if ( TRUE == pMeasurementSRV->bStartStopTimerRunning )
  912. {
  913. WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, ("***** STOP TIMER 8 *****\n") );
  914. os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
  915. pMeasurementSRV->bStartStopTimerRunning = FALSE;
  916. }
  917. for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
  918. {
  919. if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
  920. {
  921. os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
  922. pMeasurementSRV->bRequestTimerRunning[ i ] = FALSE;
  923. }
  924. }
  925. measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
  926. MSR_SRV_EVENT_START_FAILURE );
  927. }
  928. }
  929. /**
  930. * \author Ronen Kalish\n
  931. * \date 23-December-2005\n
  932. * \brief Handles a stop request when no stop is needed (SM is either idle or already send stop command to FW.\n
  933. *
  934. * Function Scope \e Private.\n
  935. * \param hMeasurementSrv - handle to the measurement SRV object.\n
  936. * \return always OK.\n
  937. */
  938. TI_STATUS measurementSRVSRVSM_dummyStop( TI_HANDLE hMeasurementSrv )
  939. {
  940. measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSrv;
  941. WLAN_REPORT_WARNING( pMeasurementSRV->hReport, MEASUREMENT_SRV_MOD

Large files files are truncated, but you can click here to view the full file