diff options
author | Dmitry Shmidt <dimitrysh@google.com> | 2013-01-17 14:02:41 -0800 |
---|---|---|
committer | Dmitry Shmidt <dimitrysh@google.com> | 2013-01-17 14:02:41 -0800 |
commit | d100419a8d5f1acc1c68fa227afb507a9bd07f42 (patch) | |
tree | 2d82c08616155a589cc57884c2469f8478292858 /wl1271/TWD/MacServices | |
parent | cece92a8acff0a81868e6cac326bcf61e54c5aec (diff) | |
download | wlan-d100419a8d5f1acc1c68fa227afb507a9bd07f42.tar.gz |
wl1271: Remove obsolete filesHEADandroid-4.3_r3.1android-4.3_r3android-4.3_r2.3android-4.3_r2.2android-4.3_r2.1android-4.3_r2android-4.3_r1.1android-4.3_r1android-4.3_r0.9.1android-4.3_r0.9android-4.3.1_r1tools_r22.2masterjb-mr2.0.0-releasejb-mr2.0-releasejb-mr2-releasejb-mr2-dev
Change-Id: I19c9ee8b975db9d6946c39529a4b01e3ba75b098
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'wl1271/TWD/MacServices')
-rw-r--r-- | wl1271/TWD/MacServices/Export_Inc/MacServices_api.h | 524 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/Export_Inc/measurementSrvDbgPrint.h | 101 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/MacServices.c | 376 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/MacServices.h | 52 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/MeasurementSrv.c | 1080 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/MeasurementSrv.h | 327 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/MeasurementSrvSM.c | 1063 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/MeasurementSrvSM.h | 261 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/PowerSrv.c | 812 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/PowerSrv.h | 194 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/PowerSrvSM.c | 814 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/PowerSrvSM.h | 281 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/PowerSrv_API.h | 281 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/ScanSrv.c | 756 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/ScanSrv.h | 308 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/ScanSrvSM.c | 584 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/ScanSrvSM.h | 212 | ||||
-rw-r--r-- | wl1271/TWD/MacServices/measurementSrvDbgPrint.c | 91 |
18 files changed, 0 insertions, 8117 deletions
diff --git a/wl1271/TWD/MacServices/Export_Inc/MacServices_api.h b/wl1271/TWD/MacServices/Export_Inc/MacServices_api.h deleted file mode 100644 index e547615f..00000000 --- a/wl1271/TWD/MacServices/Export_Inc/MacServices_api.h +++ /dev/null @@ -1,524 +0,0 @@ -/* - * MacServices_api.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file MacServicesApi.h - * \brief This file include public definitions for the MacServices module, comprising its API. - * \author Yuval Adler - * \date 6-Oct-2005 - */ - -#ifndef __MACSERVICESAPI_H__ -#define __MACSERVICESAPI_H__ - -#include "osApi.h" - -/* - *********************************************************************** - * Constant definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * Enums. - *********************************************************************** - */ - -/* - *********************************************************************** - * Typedefs. - *********************************************************************** - */ - - - -/* - *********************************************************************** - * Structure definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External data definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External functions definitions - *********************************************************************** - */ -/** - * \author Yuval Adler\n - * \date 6-Oct-2004\n - * \brief Creates MacServices module - * - * Function Scope \e Public.\n - * \param hOS - handle to the OS object.\n - */ -TI_HANDLE MacServices_create( TI_HANDLE hOS ); - -/** - * \author Yuval Adler\n - * \date 6-Oct-2004\n - * \brief Destroys MacServices module - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - */ -void MacServices_destroy( TI_HANDLE hMacServices ); - -/** - * \author Yuval Adler\n - * \date 6-Oct-2004\n - * \brief Initializes the MacServices module - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the Mac Services object.\n - * \param hReport - handle to the report object.\n - * \param hTWD - handle to the HAL ctrl object.\n - * \param hCmdBld - handle to the HAL ctrl object.\n - * \param hEventMbpx - handle to the HAL ctrl object.\n - */ -void MacServices_init (TI_HANDLE hMacServices, - TI_HANDLE hReport, - TI_HANDLE hTWD, - TI_HANDLE hCmdBld, - TI_HANDLE hEventMbox, - TI_HANDLE hTimer); -void MacServices_config (TI_HANDLE hMacServices, TTwdInitParams *pInitParams); -void MacServices_restart (TI_HANDLE hMacServices); - -void MacServices_registerFailureEventCB (TI_HANDLE hMacServices, void * failureEventCB, TI_HANDLE hFailureEventObj); - - -/*********************************************************************** - * Scan SRV API functions - ***********************************************************************/ - - -/** - * \author Ronen Kalish\n - * \date 29-Dec-2004\n - * \brief Registers a complete callback for scan complete notifications. - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param scanCompleteCB - the complete callback function.\n - * \param hScanCompleteObj - handle to the object passed to the scan complete callback function.\n - */ -void MacServices_scanSRV_registerScanCompleteCB( TI_HANDLE hMacServices, - TScanSrvCompleteCb scanCompleteCB, TI_HANDLE hScanCompleteObj ); - - - -/** - * \author Ronen Kalish\n - * \date 29-Dec-2004\n - * \brief Performs a scan - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param scanParams - the scan specific parameters.\n - * \param eScanTag - tag used for result and scan complete tracking - * \param bHighPriority - whether to perform a high priority (overlaps DTIM) scan.\n - * \param bDriverMode - whether to try to enter driver mode (with PS on) before issuing the scan command.\n - * \param bScanOnDriverModeError - whether to proceed with the scan if requested to enter driver mode and failed.\n - * \param bSendNullData - whether to send Null data when exiting driver mode on scan complete.\n - * \param psRequest - Parameter sent to PowerSaveServer on PS request to indicate PS on or "keep current" - * \param commandResponseFunc - CB function which called after downloading the command. \n - * \param commandResponseObj - The CB function Obj (Notice : last 2 params are NULL in Legacy run). \n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_scanSRV_scan( TI_HANDLE hMacServices, TScanParams *scanParams, EScanResultTag eScanTag, - TI_BOOL bHighPriority, TI_BOOL bDriverMode, TI_BOOL bScanOnDriverModeError, - E80211PsMode psRequest, TI_BOOL bSendNullData, - TCmdResponseCb commandResponseFunc, TI_HANDLE commandResponseObj ); - -/** - * \author Ronen Kalish\n - * \date 29-Dec-2004\n - * \brief Stops a scan in progress - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param eScanTag - scan tag, used for scan complete and result tracking - * \param bSendNullData - indicates whether to send Null data when exiting driver mode.\n - * \param commandResponseFunc - CB function which called after downloading the command. \n - * \param commandResponseObj - The CB function Obj (Notice : last 2 params are NULL in Legacy run). \n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_scanSRV_stopScan( TI_HANDLE hMacServices, EScanResultTag eScanTag, TI_BOOL bSendNullData, - TCmdResponseCb commandResponseFunc, TI_HANDLE commandResponseObj ); - -/** - * \author Ronen Kalish\n - * \date 17-Jan-2005\n - * \brief Notifies the scan SRV of a FW reset (that had originally been reported by a different module).\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_scanSRV_stopOnFWReset( TI_HANDLE hMacServices ); - -/** - * \author Ronen Kalish\n - * \date 29-Dec-2004\n - * \brief callback function used by the power manager to notify driver mode result - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param psStatus - the power save request status.\n - */ -void MacServices_scanSRV_powerSaveCB( TI_HANDLE hScanSRV, TI_UINT8 PSMode,TI_UINT8 psStatus ); - -/** - * \author Ronen Kalish\n - * \date 29-Dec-2004\n - * \brief Callback function used by the HAL ctrl to notify scan complete - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param str - pointer to scan result buffer (holding SPS status for SPS scan only!).\n - * \param strLen - scan result buffer length (should ALWAYS be 2, even for non SPS scans).\n - */ -void MacServices_scanSRV_scanCompleteCB( TI_HANDLE hScanSRV, char* str, TI_UINT32 strLen ); - -/** - * \author Ronen Kalish\n - * \date 29-Dec-2004\n - * \brief called when a scan timer expires. Completes the scan and starts a recovery process. - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - */ -void MacServices_scanSRV_scanTimerExpired (TI_HANDLE hScanSRV, TI_BOOL bTwdInitOccured); - -void MacServices_scanSrv_UpdateDtimTbtt (TI_HANDLE hMacServices, - TI_UINT8 uDtimPeriod, - TI_UINT16 uBeaconInterval); - -#ifdef TI_DBG -/** - * \author Shirit Brook\n - * \date God knows when...\n - * \brief Prints Scan Server SM status.\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the Mac Services object.\n - */ -void MacServices_scanSrv_printDebugStatus(TI_HANDLE hMacServices); -#endif - -/*Power server API*/ - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief request PS by User - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) hPowerSrv - handle to the PowerSrv object.\n - * 2) psMode - Power save/Active request.\n - * 3) sendNullDataOnExit - \n - * 4) powerSaveCompleteCBObject - handle to the Callback functin module.\n - * 5) powerSaveCompleteCB - Calback function - for success/faild notification.\n - * 6) powerSavecmdResponseCB - Calback function - for GWSI success/faild notification.\n - * Return Value: TI_STATUS - TI_OK / PENDING / TI_NOK.\n - * \b Description:\n - * This function is a user mode request from the Power Save Server./n - * it will create a Request from typ "USER_REQUEST" and will try to perform the user request for PS/Active./n - * this will be done in respect of priority to Driver request./n - */ -TI_STATUS MacServices_powerSrv_SetPsMode(TI_HANDLE hMacServices, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCompleteCBObject, - TPowerSaveCompleteCb powerSaveCompleteCB, - TPowerSaveResponseCb powerSavecmdResponseCB); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief SW configure, use to override the current PowerMode (what ever it will be) to - * active/PS combined with awake/power-down. use for temporary change the system policy. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * 2) powerSrv_RequestFor_802_11_PS_e - the driver mode obliged to be in 802.11 PS or not change.\n - * 3) PowerCtrl_PowerLevel_e - the desired driver power level (allowed: AWAKE or POWER DOWN).\n - * 4) TI_HANDLE theObjectHandle - the handle the object that need the PS success/fail notification.\n - * 5) ps802_11_NotificationCB_t - the callback function.\n - * 6) char* - the clinet name that ask for driver mode.\n - * Return Value: TI_STATUS - if success (already in power save) then TI_OK,\n - * if pend (wait to ACK form AP for the null data frame) then PENDING\n - * if PS isn't enabled then POWER_SAVE_802_11_NOT_ALLOWED\n - * else TI_NOK.\n - * \b Description:\n - * enter in to configuration of the driver that in higher priority from the user.\n - * the configuration is:\n - * - to enter to802.11 PS or not (if not this isn't a request to get out from 802.11 PS).\n - * - to change the HW power level to awake or power-down if not already there. - * this is a must request.\n -*/ -TI_STATUS MacServices_powerSrv_ReservePS( TI_HANDLE hMacServices, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - TPowerSaveCompleteCb powerSaveCompleteCB); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief end the temporary change of system policy, and returns to the user system policy. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * 2) char* - the clinet name that ask for driver mode.\n - * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n - * \b Description:\n - * enter in to configuration of the driver that in higher priority from the user.\n - * the configuration is:\n - * end the user mode configuration (driver mode priority) and returns the user configuration - * (user mode priority). -*/ -TI_STATUS MacServices_powerSrv_ReleasePS( TI_HANDLE hMacServices, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - TPowerSaveCompleteCb powerSaveCompleteCB); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief reflects the actual state of the state machine - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * Return Value:\n - * TI_BOOL - thre is in PS false otherwise.\n -*/ -TI_BOOL MacServices_powerSrv_getPsStatus(TI_HANDLE hMacServices); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \sets the rate as got from user else sets default value.\n - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * 2) TI_UINT16 - desierd rate .\n - * Return Value:\n - * void.\n -*/ -void MacServices_powerSrv_SetRateModulation(TI_HANDLE hMacServices, TI_UINT16 rate); -/** - * \Return the alrweady seted rate.\n - * - * Function Scope \e Public.\n - * Parameters:\n - * TI_HANDLE - handle to the powerSrv object.\n - * Return Value: TI_UINT16 - desierd rate .\n - * void.\n -*/ -TI_UINT32 MacServices_powerSrv_GetRateModulation(TI_HANDLE hMacServices); - - - - -/*********************************************************************** - * Measurement SRV API functions - ***********************************************************************/ - -/** - * \author Ronen Kalish\n - * \date 09-November-2005\n - * \brief Starts a measurement operation.\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param pMsrRequest - a structure containing measurement parameters.\n - * \param timeToRequestExpiryMs - the time (in milliseconds) the measurement SRV has to start the request.\n - * \param cmdResponseCBFunc - callback function to used for command response.\n - * \param cmdResponseCBObj - handle to pass to command response CB.\n - * \param cmdCompleteCBFunc - callback function to be used for command complete.\n - * \param cmdCompleteCBObj - handle to pass to command complete CB.\n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_measurementSRV_startMeasurement( TI_HANDLE hMacServices, - TMeasurementRequest* pMsrRequest, - TI_UINT32 timeToRequestExpiryMs, - TCmdResponseCb cmdResponseCBFunc, - TI_HANDLE cmdResponseCBObj, - TMeasurementSrvCompleteCb cmdCompleteCBFunc, - TI_HANDLE cmdCompleteCBObj ); - -/** - * \author Ronen Kalish\n - * \date 09-November-2005\n - * \brief Stops a measurement operation in progress.\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param bSendNullData - whether to send NULL data when exiting driver mode.\n - * \param cmdResponseCBFunc - callback function to used for command response.\n - * \param cmdResponseCBObj - handle to pass to command response CB.\n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_measurementSRV_stopMeasurement( TI_HANDLE hMacServices, - TI_BOOL bSendNullData, - TCmdResponseCb cmdResponseCBFunc, - TI_HANDLE cmdResponseCBObj ); - -/** - * \author Ronen Kalish\n - * \date 09-November-2005\n - * \brief Notifies the measurement SRV of a FW reset (recovery).\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - */ -void MacServices_measurementSRV_FWReset( TI_HANDLE hMacServices ); - -/** - * \author Ronen Kalish\n - * \date 09-November-2005\n - * \brief callback function used by the power manager to notify driver mode result - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param PSMode - the power save mode the STA is currently in.\n - * \param psStatus - the power save request status.\n - */ -void MacServices_measurementSRV_powerSaveCB( TI_HANDLE hMeasurementSRV, TI_UINT8 PSMode,TI_UINT8 psStatus ); - -/** - * \author Ronen Kalish\n - * \date 14-November-2005\n - * \brief callback function used by the HAL for measure start event (sent when the FW - * has started measurement operation, i.e. switched channel and changed RX filters).\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_measureStartCB( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 14-November-2005\n - * \brief callback function used by the HAL for measure stop event (sent when the FW - * has finished measurement operation, i.e. switched channel to serving channel and changed back RX filters).\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_measureCompleteCB( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 14-November-2005\n - * \brief callback function used by the HAL for AP discovery stop event (sent when the FW - * has finished AP discovery operation).\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_apDiscoveryCompleteCB( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 16-November-2005\n - * \brief Callback for channel load get param call.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param status - the get_param call status.\n - * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) - */ -void MacServices_measurementSRV_channelLoadParamCB( TI_HANDLE hMeasurementSRV, TI_STATUS status, TI_UINT8* CB_buf ); - -/** - * \date 03-January-2005\n - * \brief Dummy callback for channel load get param call. Used to clear the channel load tracker.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param status - the get_param call status.\n - * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) - */ -void MacServices_measurementSRV_dummyChannelLoadParamCB( TI_HANDLE hMeasurementSRV, TI_STATUS status, TI_UINT8* CB_buf ); - -/** - * \author Ronen Kalish\n - * \date 16-November-2005\n - * \brief Callback for noise histogram get param call.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param status - the get_param call status.\n - * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) - */ -void MacServices_measurementSRV_noiseHistCallBack(TI_HANDLE hMeasurementSRV, TI_STATUS status, TI_UINT8* CB_buf); - -/** - * \author Ronen Kalish\n - * \date 14-November-2005\n - * \brief called when a measurement FW guard timer expires. - * - * Function Scope \e Public.\n - * \param hMeasuremntSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_startStopTimerExpired (TI_HANDLE hMeasurementSRV, TI_BOOL bTwdInitOccured); - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief called when a measurement type timer expires.\n - * - * Function Scope \e Public.\n - * \param hMeasuremntSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_requestTimerExpired (TI_HANDLE hMeasurementSRV, TI_BOOL bTwdInitOccured); - -#endif /* __MACSERVICESAPI_H__ */ diff --git a/wl1271/TWD/MacServices/Export_Inc/measurementSrvDbgPrint.h b/wl1271/TWD/MacServices/Export_Inc/measurementSrvDbgPrint.h deleted file mode 100644 index d76f4dac..00000000 --- a/wl1271/TWD/MacServices/Export_Inc/measurementSrvDbgPrint.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * measurementSrvDbgPrint.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file MeasurementSrv.h - * \brief This file include definitions for the measurmeent SRV module debug print functions. - * \author Ronen Kalish - * \date 23-december-2005 - */ - -#ifndef __MEASUREMENT_SRV__SBG_PRINT_H__ -#define __MEASUREMENT_SRV__SBG_PRINT_H__ - -/* - *********************************************************************** - * Constant definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * Enums. - *********************************************************************** - */ - -/* - *********************************************************************** - * Typedefs. - *********************************************************************** - */ - -/* - *********************************************************************** - * Structure definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External data definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External functions definitions - *********************************************************************** - */ -/** - * \author Ronen Kalish\n - * \date 23-December-2005\n - * \brief Prints a measurement request.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param pMsrRequest - the measurement request.\n - */ -void measurementSRVPrintRequest( TI_HANDLE hMeasurementSRV, TMeasurementRequest *pMsrRequest ); - -/** - * \author Ronen Kalish\n - * \date 23-December-2005\n - * \brief Prints a measurement type request.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param pMsrTypeRequest - the measurement type request.\n - */ -void measurementSRVPrintTypeRequest( TI_HANDLE hMeasurementSRV, TMeasurementTypeRequest* pMsrTypeRequest ); - -#endif /* __MEASUREMENT_SRV__SBG_PRINT_H__ */ - diff --git a/wl1271/TWD/MacServices/MacServices.c b/wl1271/TWD/MacServices/MacServices.c deleted file mode 100644 index 697be339..00000000 --- a/wl1271/TWD/MacServices/MacServices.c +++ /dev/null @@ -1,376 +0,0 @@ -/* - * MacServices.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file MacServices.c - * \brief This file include public definitions for the scan SRV module, comprising its API. - * \author Yuval Adler - * \date 6-Oct-2005 - */ - -#define __FILE_ID__ FILE_ID_109 -#include "report.h" -#include "ScanSrv.h" -#include "MeasurementSrv.h" -#include "MacServices.h" -#include "PowerSrv_API.h" - - -/**************************************************************************************** - * MacServices_create * - ***************************************************************************************** -DESCRIPTION: Creates MacServices module - -INPUT: hOS - handle to the OS object. -OUTPUT: -RETURN: handle to MacServices Object, NULL on failure . -****************************************************************************************/ - -TI_HANDLE MacServices_create( TI_HANDLE hOS) -{ - MacServices_t *pMacServices = (MacServices_t*)os_memoryAlloc( hOS, sizeof(MacServices_t) ); - if ( NULL == pMacServices ) - { - WLAN_OS_REPORT( ("ERROR: Failed to create Mac SRV module") ); - return NULL; - } - - /* nullify all handles, so that only handles in existence will be released */ - pMacServices->hScanSRV = NULL; - pMacServices->hPowerSrv = NULL; - - /* create the scanSRV handle */ - pMacServices->hScanSRV = MacServices_scanSRV_create(hOS); - if ( NULL == pMacServices->hScanSRV ) - { - MacServices_destroy( pMacServices ); - return NULL; - } - -/* create the measurment handle */ - pMacServices->hMeasurementSRV = MacServices_measurementSRV_create( hOS ); - if ( NULL == pMacServices->hMeasurementSRV ) - { - MacServices_destroy(pMacServices); - return NULL; - } - - pMacServices->hPowerSrv = powerSrv_create(hOS); - if (NULL == pMacServices->hPowerSrv ) - { - MacServices_destroy(pMacServices); - return NULL; - } - - /* store OS handle */ - pMacServices->hOS = hOS; - - return pMacServices; -} - - - -/**************************************************************************************** - * MacServices_destroy * - ***************************************************************************************** -DESCRIPTION: destroys MacServices module - -INPUT: hMacServices - handle to the Mac Services object. -OUTPUT: -RETURN: -****************************************************************************************/ -void MacServices_destroy( TI_HANDLE hMacServices ) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - /* destroy all SRV modules */ - if ( NULL != pMacServices->hScanSRV ) - { - MacServices_scanSRV_destroy( pMacServices->hScanSRV ); - } - if ( NULL != pMacServices->hMeasurementSRV ) - { - MacServices_measurementSRV_destroy( pMacServices->hMeasurementSRV ); - } - - if(pMacServices->hPowerSrv) - powerSrv_destroy(pMacServices->hPowerSrv); - - /* free the Mac services allocated context */ - os_memoryFree( pMacServices->hOS, (TI_HANDLE)pMacServices , sizeof(MacServices_t) ); -} - - - /**************************************************************************************** - * MacServices_init * - ***************************************************************************************** -DESCRIPTION: Initializes the MacServices module - -INPUT: hMacServices - handle to the Mac Services object.\n - hReport - handle to the report object.\n - hHalCtrl - handle to the HAL ctrl object.\n -OUTPUT: -RETURN: -****************************************************************************************/ -void MacServices_init (TI_HANDLE hMacServices, - TI_HANDLE hReport, - TI_HANDLE hTWD, - TI_HANDLE hCmdBld, - TI_HANDLE hEventMbox, - TI_HANDLE hTimer) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - MacServices_scanSRV_init (hMacServices, hReport, hTWD, hTimer, hEventMbox, hCmdBld); - - MacServices_measurementSRV_init (pMacServices->hMeasurementSRV, - hReport, - hCmdBld, - hEventMbox, - pMacServices->hPowerSrv, - hTimer); - - if (powerSrv_init (pMacServices->hPowerSrv, - hReport, - hEventMbox, - hCmdBld, - hTimer) != TI_OK) - { - WLAN_OS_REPORT(("\n.....PowerSRV_init configuration failure \n")); - /*return TI_NOK;*/ - } -} - - - /**************************************************************************************** - * MacServices_config * - ***************************************************************************************** -DESCRIPTION: config the MacServices moduleand sub modules - -INPUT: hMacServices - handle to the Mac Services object.\n - pInitParams - pointer to the init params -OUTPUT: -RETURN: -****************************************************************************************/ -void MacServices_config( TI_HANDLE hMacServices, TTwdInitParams *pInitParams) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - if (powerSrv_config(pMacServices->hPowerSrv,&pInitParams->tPowerSrv) != TI_OK) - { - WLAN_OS_REPORT(("\n.....PowerSRV_config failure \n")); - } - - MacServices_scanSrv_config (pMacServices, &pInitParams->tScanSrv); -} - - /**************************************************************************************** - * MacServices_restart * - ***************************************************************************************** -DESCRIPTION: restart the MacServices moduleand sub modules upon recovery - -INPUT: hMacServices - handle to the Mac Services object.\n -OUTPUT: -RETURN: -****************************************************************************************/ -void MacServices_restart (TI_HANDLE hMacServices) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - scanSRV_restart (pMacServices->hScanSRV); - measurementSRV_restart (pMacServices->hMeasurementSRV); - powerSrv_restart (pMacServices->hPowerSrv); -} - - -/**************************************************************************************** - * MacServices_registerFailureEventCB * - ***************************************************************************************** -DESCRIPTION: register the centeral error function from the health monitor to the MacService's sub modules - -INPUT: hMacServices - handle to the Mac Services object. - failureEventCB - pointer ro the call back - hFailureEventObj -handle of the Callback Object -OUTPUT: -RETURN: -****************************************************************************************/ - -void MacServices_registerFailureEventCB (TI_HANDLE hMacServices, - void * failureEventCB, - TI_HANDLE hFailureEventObj) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - powerSrvRegisterFailureEventCB (pMacServices->hPowerSrv, - failureEventCB, - hFailureEventObj); - - measurementSRVRegisterFailureEventCB (pMacServices->hMeasurementSRV, - failureEventCB, - hFailureEventObj); - - scanSRV_registerFailureEventCB (pMacServices->hScanSRV, - failureEventCB, - hFailureEventObj); - -} - -/**************************************************************************************** - * MacServices_powerSrv_SetPsMode * - **************************************************************************************** -DESCRIPTION: This function is a wrapper for the power server's powerSrv_SetPsMode function - -INPUT: - hMacServices - handle to the Mac services object. - - psMode - Power save/Active request - - sendNullDataOnExit - - - powerSaveCBObject - handle to the Callback function module. - - powerSaveCompleteCB - Callback function - for success/faild notification. -OUTPUT: -RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. -****************************************************************************************/ - -TI_STATUS MacServices_powerSrv_SetPsMode (TI_HANDLE hMacServices, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCompleteCBObject, - TPowerSaveCompleteCb powerSaveCompleteCB, - TPowerSaveResponseCb powerSavecmdResponseCB) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - return powerSrv_SetPsMode (pMacServices->hPowerSrv, - psMode, - sendNullDataOnExit, - powerSaveCompleteCBObject, - powerSaveCompleteCB, - powerSavecmdResponseCB); -} - - -/**************************************************************************************** - * MacServices_powerSrv_ReservePS * - **************************************************************************************** -DESCRIPTION: This function is a wrapper for the power server's powerSrv_ReservePS function - -INPUT: - hMacServices - handle to the Mac services object. - - psMode - Power save/Active request - - sendNullDataOnExit - - - powerSaveCBObject - handle to the Callback function module. - - powerSaveCompleteCB - Callback function - for success/faild notification. -OUTPUT: -RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. -****************************************************************************************/ -TI_STATUS MacServices_powerSrv_ReservePS( TI_HANDLE hMacServices, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - TPowerSaveCompleteCb powerSaveCompleteCB) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - return powerSrv_ReservePS(pMacServices->hPowerSrv,psMode,sendNullDataOnExit,powerSaveCBObject,powerSaveCompleteCB); -} - - -/**************************************************************************************** - * MacServices_powerSrv_ReleasePS * - **************************************************************************************** -DESCRIPTION: This function is a wrapper for the power server's powerSrv_ReleasePS function - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - sendNullDataOnExit - - - powerSaveCBObject - handle to the Callback function module. - - powerSaveCompleteCB - Callback function - for success/faild notification. -OUTPUT: -RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. -****************************************************************************************/ - -TI_STATUS MacServices_powerSrv_ReleasePS( TI_HANDLE hMacServices, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - TPowerSaveCompleteCb powerSaveCompleteCB) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - return powerSrv_ReleasePS(pMacServices->hPowerSrv,sendNullDataOnExit,powerSaveCBObject,powerSaveCompleteCB); -} - - -/**************************************************************************************** - * MacServices_powerSrv_getPsStatus * - ***************************************************************************************** -DESCRIPTION: This function is a wrapper for the power server's powerSrv_getPsStatus function - -INPUT: - hPowerSrv - handle to the PowerSrv object. - -OUTPUT: -RETURN: TI_BOOL - true if the SM is in PS state - false otherwise -****************************************************************************************/ -TI_BOOL MacServices_powerSrv_getPsStatus(TI_HANDLE hMacServices) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - return powerSrv_getPsStatus( pMacServices->hPowerSrv); -} - - - /**************************************************************************************** - * MacServices_powerSrv_SetRateModulation * - ***************************************************************************************** -DESCRIPTION: This function is a wrapper for the power server's powerSrv_SetRateModulation function - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - dot11mode_e - The current radio mode (A or G) - -OUTPUT: -RETURN: TI_BOOL - true if the SM is in PS state - false otherwise -****************************************************************************************/ -void MacServices_powerSrv_SetRateModulation(TI_HANDLE hMacServices, TI_UINT16 rate) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - powerSrv_SetRateModulation( pMacServices->hPowerSrv, rate); -} - - -TI_UINT32 MacServices_powerSrv_GetRateModulation(TI_HANDLE hMacServices) -{ - MacServices_t *pMacServices = (MacServices_t*)hMacServices; - - return powerSrv_GetRateModulation( pMacServices->hPowerSrv); -} - - - - - - diff --git a/wl1271/TWD/MacServices/MacServices.h b/wl1271/TWD/MacServices/MacServices.h deleted file mode 100644 index a92551c6..00000000 --- a/wl1271/TWD/MacServices/MacServices.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * MacServices.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file MacServices.h - * \brief This file include internal definitions for the MacServices module - * \author Yuval Adler - * \date 6-Oct-2005 - */ - - -#ifndef __MACSERVICES_H__ -#define __MACSERVICES_H__ - -typedef struct -{ - TI_HANDLE hOS; - TI_HANDLE hScanSRV; - TI_HANDLE hMeasurementSRV; - TI_HANDLE hPowerSrv; -} MacServices_t ; - -#endif /* __MACSERVICES_H__ */ diff --git a/wl1271/TWD/MacServices/MeasurementSrv.c b/wl1271/TWD/MacServices/MeasurementSrv.c deleted file mode 100644 index d780a79c..00000000 --- a/wl1271/TWD/MacServices/MeasurementSrv.c +++ /dev/null @@ -1,1080 +0,0 @@ -/* - * MeasurementSrv.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file measurementSrv.c - * \brief This file include the measurement SRV interface functions implementation. - * \author Ronen Kalish - * \date 09-November-2005 - */ - -#define __FILE_ID__ FILE_ID_110 -#include "tidef.h" -#include "MeasurementSrv.h" -#include "MeasurementSrvSM.h" -#include "report.h" -#include "timer.h" -#include "osApi.h" -#include "MacServices.h" -#include "measurementSrvDbgPrint.h" -#include "eventMbox_api.h" -#include "CmdBld.h" - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Creates the measurement SRV object - * - * Function Scope \e Public.\n - * \param hOS - handle to the OS object.\n - * \return a handle to the measurement SRV object, NULL if an error occurred.\n - */ -TI_HANDLE MacServices_measurementSRV_create( TI_HANDLE hOS ) -{ - measurementSRV_t* pMeasurementSRV; - - /* allocate the measurement SRV object */ - pMeasurementSRV = os_memoryAlloc( hOS, sizeof(measurementSRV_t)); - if ( NULL == pMeasurementSRV ) - { - WLAN_OS_REPORT( ("ERROR: Failed to create measurement SRV object.")); - return NULL; - } - - /* nullify the object */ - os_memoryZero( hOS, pMeasurementSRV, sizeof(measurementSRV_t)); - - /* store OS handle */ - pMeasurementSRV->hOS = hOS; - - /* allocate the SM */ - if ( TI_OK != fsm_Create( hOS, &(pMeasurementSRV->SM), MSR_SRV_NUM_OF_STATES, MSR_SRV_NUM_OF_EVENTS )) - { - pMeasurementSRV->SM = NULL; - WLAN_OS_REPORT(("Failed to create measurement SRV state machine.\n")); - MacServices_measurementSRV_destroy( pMeasurementSRV ); - return NULL; - } - - return (TI_HANDLE)pMeasurementSRV; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Initializes the measurement SRV object - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param hReport - handle to the report object.\n - * \param hCmdBld - handle to the Command Builder object.\n - * \param hPowerSaveSRV - handle to the power save SRV object.\n - */ -TI_STATUS MacServices_measurementSRV_init (TI_HANDLE hMeasurementSRV, - TI_HANDLE hReport, - TI_HANDLE hCmdBld, - TI_HANDLE hEventMbox, - TI_HANDLE hPowerSaveSRV, - TI_HANDLE hTimer) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - - /* store handles */ - pMeasurementSRV->hReport = hReport; - pMeasurementSRV->hCmdBld = hCmdBld; - pMeasurementSRV->hEventMbox = hEventMbox; - pMeasurementSRV->hPowerSaveSRV = hPowerSaveSRV; - pMeasurementSRV->hTimer = hTimer; - - /* Initialize the state machine */ - measurementSRVSM_init (hMeasurementSRV); - - /* allocate the module timers */ - pMeasurementSRV->hStartStopTimer = tmr_CreateTimer (pMeasurementSRV->hTimer); - if (pMeasurementSRV->hStartStopTimer == NULL) - { - TRACE0(pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, "MacServices_measurementSRV_init(): Failed to create hStartStopTimer!\n"); - return TI_NOK; - } - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - - for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) - { - pMeasurementSRV->hRequestTimer[i] = tmr_CreateTimer (pMeasurementSRV->hTimer); - if (pMeasurementSRV->hRequestTimer[i] == NULL) - { - TRACE0(pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, "MacServices_measurementSRV_init(): Failed to create hRequestTimer!\n"); - return TI_NOK; - } - pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; - } - - /* register HAL callbacks */ - /* Register and Enable the Measure Start event in HAL */ - - - eventMbox_RegisterEvent (pMeasurementSRV->hEventMbox, - TWD_OWN_EVENT_MEASUREMENT_START, - (void *)MacServices_measurementSRV_measureStartCB, - hMeasurementSRV); - eventMbox_UnMaskEvent (pMeasurementSRV->hEventMbox, TWD_OWN_EVENT_MEASUREMENT_START, NULL, NULL); - - /* Register and Enable the Measurement Complete event in HAL. - This event will be received when the Measurement duration expired, - or after Stop Measure command. */ - - eventMbox_RegisterEvent (pMeasurementSRV->hEventMbox, - TWD_OWN_EVENT_MEASUREMENT_COMPLETE, - (void *)MacServices_measurementSRV_measureCompleteCB, - hMeasurementSRV); - eventMbox_UnMaskEvent (pMeasurementSRV->hEventMbox, TWD_OWN_EVENT_MEASUREMENT_COMPLETE, NULL, NULL); - - /* Register and Enable the AP Discovery Complete event in HAL */ - eventMbox_RegisterEvent (pMeasurementSRV->hEventMbox, - TWD_OWN_EVENT_AP_DISCOVERY_COMPLETE, - (void *)MacServices_measurementSRV_apDiscoveryCompleteCB, - hMeasurementSRV); - eventMbox_UnMaskEvent (pMeasurementSRV->hEventMbox, TWD_OWN_EVENT_AP_DISCOVERY_COMPLETE, NULL, NULL); - - TRACE0(hReport, REPORT_SEVERITY_INIT , ".....Measurement SRV configured successfully.\n"); - - return TI_OK; -} - -/** - * \brief Restart the measurement SRV object upon recovery. - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void measurementSRV_restart( TI_HANDLE hMeasurementSRV) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - - /* if a timer is running, stop it */ - if (pMeasurementSRV->bStartStopTimerRunning) - { - tmr_StopTimer (pMeasurementSRV->hStartStopTimer); - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - } - for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) - { - if (pMeasurementSRV->bRequestTimerRunning[i]) - { - tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]); - pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; - } - } - - - /* Initialize the state machine */ - /* initialize current state */ - pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE; - - /* mark that all timers are not running */ - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) - { - pMeasurementSRV->bRequestTimerRunning[ i ] = TI_FALSE; - } - -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Destroys the measurement SRV object - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_destroy( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - - /* sanity cehcking */ - if ( NULL == hMeasurementSRV ) - { - return; - } - - /* release state machine */ - if ( NULL != pMeasurementSRV->SM ) - { - fsm_Unload( pMeasurementSRV->hOS, pMeasurementSRV->SM ); - } - - /* release timers */ - for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) - { - if (pMeasurementSRV->hRequestTimer[i]) - { - tmr_DestroyTimer (pMeasurementSRV->hRequestTimer[i]); - } - } - if (pMeasurementSRV->hStartStopTimer) - { - tmr_DestroyTimer (pMeasurementSRV->hStartStopTimer); - } - - /* release object space */ - os_memoryFree( pMeasurementSRV->hOS, (TI_HANDLE)pMeasurementSRV, sizeof(measurementSRV_t)); -} - -/** - * \author Ronen Kalish\n - * \date 09-November-2005\n - * \brief Starts a measurement operation.\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param pMsrRequest - a structure containing measurement parameters.\n - * \param timeToRequestexpiryMs - the time (in milliseconds) the measurement SRV has to start the request.\n - * \param cmdResponseCBFunc - callback function to used for command response.\n - * \param cmdResponseCBObj - handle to pass to command response CB.\n - * \param cmdCompleteCBFunc - callback function to be used for command complete.\n - * \param cmdCompleteCBObj - handle to pass to command complete CB.\n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_measurementSRV_startMeasurement( TI_HANDLE hMacServices, - TMeasurementRequest* pMsrRequest, - TI_UINT32 timeToRequestExpiryMs, - TCmdResponseCb cmdResponseCBFunc, - TI_HANDLE cmdResponseCBObj, - TMeasurementSrvCompleteCb cmdCompleteCBFunc, - TI_HANDLE cmdCompleteCBObj ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)((MacServices_t*)hMacServices)->hMeasurementSRV; - TI_INT32 i; - -#ifdef TI_DBG -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Received measurement request.\n"); - measurementSRVPrintRequest( (TI_HANDLE)pMeasurementSRV, pMsrRequest ); -TRACE3( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "time to expiry: %d ms, cmd response CB: 0x%x, cmd response handle: 0x%x\n", timeToRequestExpiryMs, cmdResponseCBFunc, cmdResponseCBObj); -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "cmd complete CB: 0x%x, cmd complete handle: 0x%x\n", cmdCompleteCBFunc, cmdCompleteCBObj); -#endif - - /* mark that request is in progress */ - pMeasurementSRV->bInRequest = TI_TRUE; - - /* mark to send NULL data when exiting driver mode (can be changed to TI_FALSE - only when explictly stopping the measurement */ - pMeasurementSRV->bSendNullDataWhenExitPs = TI_TRUE; - - /* Nullify return status */ - pMeasurementSRV->returnStatus = TI_OK; - - /* copy request parameters */ - os_memoryCopy (pMeasurementSRV->hOS, - (void *)&pMeasurementSRV->msrRequest, - (void *)pMsrRequest, - sizeof(TMeasurementRequest)); - - /* Mark the current time stamp and the duration to start to cehck expiry later */ - pMeasurementSRV->requestRecptionTimeStampMs = os_timeStampMs( pMeasurementSRV->hOS ); - pMeasurementSRV->timeToRequestExpiryMs = timeToRequestExpiryMs; - - /* copy callbacks */ - pMeasurementSRV->commandResponseCBFunc = cmdResponseCBFunc; - pMeasurementSRV->commandResponseCBObj = cmdResponseCBObj; - pMeasurementSRV->measurmentCompleteCBFunc = cmdCompleteCBFunc; - pMeasurementSRV->measurementCompleteCBObj = cmdCompleteCBObj; - - /* initialize reply */ - pMeasurementSRV->msrReply.numberOfTypes = pMsrRequest->numberOfTypes; - for ( i = 0; i < pMsrRequest->numberOfTypes; i++ ) - { - pMeasurementSRV->msrReply.msrTypes[ i ].msrType = pMeasurementSRV->msrRequest.msrTypes[ i ].msrType; - pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_OK; - } - - /* nullify the pending CBs bitmap */ - pMeasurementSRV->pendingParamCBs = 0; - - /* send a start measurement event to the SM */ - measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_MEASURE_START_REQUEST ); - - /* mark that request has been sent */ - pMeasurementSRV->bInRequest = TI_FALSE; - - return pMeasurementSRV->returnStatus; -} - -/** - * \author Ronen Kalish\n - * \date 09-November-2005\n - * \brief Stops a measurement operation in progress.\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param bSendNullData - whether to send NULL data when exiting driver mode.\n - * \param cmdResponseCBFunc - callback function to used for command response.\n - * \param cmdResponseCBObj - handle to pass to command response CB.\n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_measurementSRV_stopMeasurement( TI_HANDLE hMacServices, - TI_BOOL bSendNullData, - TCmdResponseCb cmdResponseCBFunc, - TI_HANDLE cmdResponseCBObj ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)((MacServices_t*)hMacServices)->hMeasurementSRV; - -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Received measurement stop request.\n"); -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "Send null data:, cmd response CB: 0x%x, cmd response handle: 0x%x\n", cmdResponseCBFunc, cmdResponseCBObj); - - /* store callbacks */ - pMeasurementSRV->commandResponseCBFunc = cmdResponseCBFunc; - pMeasurementSRV->commandResponseCBObj = cmdResponseCBObj; - - /* store NULL data indication */ - pMeasurementSRV->bSendNullDataWhenExitPs = bSendNullData; - - /* mark that current return status is TI_OK */ - pMeasurementSRV->returnStatus = TI_OK; - - /* mark that a stop request is in progress */ - pMeasurementSRV->bInRequest = TI_TRUE; - - /* send a stop event to the SM */ - measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_MEASURE_STOP_REQUEST ); - - /*mark that stop request has completed */ - pMeasurementSRV->bInRequest = TI_FALSE; - - return pMeasurementSRV->returnStatus; -} - -/** - * \author Ronen Kalish\n - * \date 09-November-2005\n - * \brief Notifies the measurement SRV of a FW reset (recovery).\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - */ -void MacServices_measurementSRV_FWReset( TI_HANDLE hMacServices ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)((MacServices_t*)hMacServices)->hMeasurementSRV; - TI_INT32 i; - -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Received FW reset indication.\n"); - - /* if a timer is running, stop it */ - if (pMeasurementSRV->bStartStopTimerRunning) - { - tmr_StopTimer (pMeasurementSRV->hStartStopTimer); - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - } - for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) - { - if (pMeasurementSRV->bRequestTimerRunning[i]) - { - tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]); - pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; - } - } - - /* change SM state to idle */ - pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE; -} - -/** - * \author Ronen Kalish\n - * \date 09-November-2005\n - * \brief callback function used by the power manager to notify driver mode result - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param PSMode - the power save mode the STA is currently in.\n - * \param psStatus - the power save request status.\n - */ -void MacServices_measurementSRV_powerSaveCB( TI_HANDLE hMeasurementSRV, TI_UINT8 PSMode, TI_UINT8 psStatus ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Power save SRV CB called. PS mode:%d status: %d\n", PSMode, psStatus); - - /* if driver mode entry succeedded */ - if ( ENTER_POWER_SAVE_SUCCESS == psStatus ) - { - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": PS successful.\n"); - - /* send a RIVER_MODE_SUCCESS event */ - measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_DRIVER_MODE_SUCCESS ); - } - /* driver mode entry failed */ - else - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": PS failed, status %d.\n", psStatus); - - /* Set the return status to TI_NOK */ - pMeasurementSRV->returnStatus = (TI_STATUS)psStatus; - - /* send a DRIVER_MODE_FAILURE event */ - measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_DRIVER_MODE_FAILURE ); - } -} - -/** - * \author Ronen Kalish\n - * \date 14-November-2005\n - * \brief callback function used by the HAL for measure start event (sent when the FW - * has started measurement operation, i.e. switched channel and changed RX filters).\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_measureStartCB( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure start CB called.\n"); - - /* stop the FW guard timer */ - tmr_StopTimer (pMeasurementSRV->hStartStopTimer); - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - - /* clear the CB function, so that it won't be called on stop as well! */ - pMeasurementSRV->commandResponseCBFunc = NULL; - pMeasurementSRV->commandResponseCBObj = NULL; - - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_START_SUCCESS ); -} - -/** - * \author Ronen Kalish\n - * \date 14-November-2005\n - * \brief callback function used by the HAL for measure stop event (sent when the FW - * has finished measurement operation, i.e. switched channel to serving channel and changed back RX filters).\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_measureCompleteCB( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure complete CB called.\n"); - - /* stop the FW guard timer */ - tmr_StopTimer (pMeasurementSRV->hStartStopTimer); - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_STOP_COMPLETE ); -} - -/** - * \author Ronen Kalish\n - * \date 14-November-2005\n - * \brief callback function used by the HAL for AP discovery stop event (sent when the FW - * has finished AP discovery operation).\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_apDiscoveryCompleteCB( TI_HANDLE hMeasurementSRV ) -{ -#ifdef TI_DBG - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": AP Discovery complete CB called.\n"); -#endif /* TI_DBG */ -} - -/** - * \author Ronen Kalish\n - * \date 14-November-2005\n - * \brief called when a measurement FW guard timer expires. - * - * Function Scope \e Public.\n - * \param hMeasuremntSRV - handle to the measurement SRV object.\n - * \param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started.\n - */ -void MacServices_measurementSRV_startStopTimerExpired (TI_HANDLE hMeasurementSRV, TI_BOOL bTwdInitOccured) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": FW guard timer expired.\n"); - - /* mark that the FW guard timer is not running */ - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - - /* if any other timer is running - stop it */ - for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) - { - if (pMeasurementSRV->bRequestTimerRunning[i]) - { - tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]); - pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; - } - } - - /* change SM state to idle */ - pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE; - - /*Error Reporting - call the centeral error function in the health monitor if a request for measurement was faield*/ - pMeasurementSRV->failureEventFunc(pMeasurementSRV->failureEventObj ,MEASUREMENT_FAILURE); -} - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief called when a measurement type timer expires.\n - * - * Function Scope \e Public.\n - * \param hMeasuremntSRV - handle to the measurement SRV object.\n - * \param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started.\n - */ -void MacServices_measurementSRV_requestTimerExpired (TI_HANDLE hMeasurementSRV, TI_BOOL bTwdInitOccured) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 requestIndex; - - /* find the expired measurement type */ - requestIndex = measurementSRVFindMinDuration( hMeasurementSRV ); - if ( -1 == requestIndex ) - { - /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Request timer expired and request index from findMinDuration is -1?!?"); - return; - } - -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": request timer expired, request index: %d.\n", requestIndex); - - /* mark that the timer is not running and that this request has completed */ - pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TI_FALSE; - - /* collect results and send stop command if necessary */ - switch (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType) - { - case MSR_TYPE_BEACON_MEASUREMENT: - measurementSRVHandleBeaconMsrComplete( hMeasurementSRV, requestIndex ); - break; - - case MSR_TYPE_CCA_LOAD_MEASUREMENT: - measurementSRVHandleChannelLoadComplete( hMeasurementSRV, requestIndex ); - break; - - case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT: - measurementSRVHandleNoiseHistogramComplete( hMeasurementSRV, requestIndex ); - break; - - /* used here to avoid compilation warning only, does nothing */ - case MSR_TYPE_BASIC_MEASUREMENT: - case MSR_TYPE_FRAME_MEASUREMENT: - case MSR_TYPE_MAX_NUM_OF_MEASURE_TYPES: - default: -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": measure type %d not supported for request %d\n", pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType, requestIndex); - break; - } - - /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */ - if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) - { - /* send the event */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); - } -} - -/** - * \author Ronen Kalish\n - * \date 13-November-2005\n - * \brief Checks whether a beacon measurement is part of current measurement request - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \return TI_TRUE if a beacon measurement is part of current request, TI_FALSE otherwise.\n - */ -TI_BOOL measurementSRVIsBeaconMeasureIncluded( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - - for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) - { - if ( MSR_TYPE_BEACON_MEASUREMENT == pMeasurementSRV->msrRequest.msrTypes[ i ].msrType ) - { - return TI_TRUE; - } - } - return TI_FALSE; -} - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief Finds the index for the measurement request with the shortest period - * (the one that has now completed).\n - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \return index of the measurement request with the shortest duration.\n - */ -TI_INT32 measurementSRVFindMinDuration( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i, minIndex; - TI_UINT32 minValue; - - - minIndex = minValue = 0; /* minIndex is initialized only to avoid compilation warning! */ - - /* find the index with the minimum duration */ - for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) - { - if ( TI_TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] ) - { - if ( (0 == minValue) || - (pMeasurementSRV->msrRequest.msrTypes[ i ].duration < minValue)) - { - minValue = pMeasurementSRV->msrRequest.msrTypes[ i ].duration; - minIndex = i; - } - } - } - - /* if no entry with positive duration exists, return -1 */ - if ( 0 == minValue ) - { - return -1; - } - else - { /* otherwise, return the index of the type with the shortest duration */ - return minIndex; - } -} - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief Handles an AP discovery timer expiry, by setting necessary values in the - * reply struct.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param requestIndex - index of the beacon request in the request structure.\n - */ -void measurementSRVHandleBeaconMsrComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 status; - - -TRACE0(pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Sending AP Discovery Stop to the HAL..."); - - /* send stop AP discovery command */ - status = cmdBld_CmdApDiscoveryStop (pMeasurementSRV->hCmdBld, NULL, NULL); - if ( TI_OK != status ) - { -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": status %d received from cmdBld_CmdApDiscoveryStop\n", status); - } -} - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief Handles a channel load timer expiry, by requesting channel load - * results from the FW.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param requestIndex - index of the channel load request in the request structure.\n - */ -void measurementSRVHandleChannelLoadComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TTwdParamInfo tTwdParam; - TI_STATUS status; - - /* Getting the Medium Occupancy Register */ - tTwdParam.paramType = TWD_MEDIUM_OCCUPANCY_PARAM_ID; - tTwdParam.content.interogateCmdCBParams.fCb = (void *)MacServices_measurementSRV_channelLoadParamCB; - tTwdParam.content.interogateCmdCBParams.hCb = hMeasurementSRV; - tTwdParam.content.interogateCmdCBParams.pCb = (TI_UINT8*)(&(pMeasurementSRV->mediumOccupancyResults)); - status = cmdBld_GetParam (pMeasurementSRV->hCmdBld, &tTwdParam); - - if ( status != TI_OK ) - { -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": whalCtrl_GetParam returned status %d\n", status); - - /* mark that the specific measurment type has failed */ - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; - - /* if all measurement types has finished, an event will be send by request timer expired */ - } - else - { - /* mark that channel load param CB is pending */ - pMeasurementSRV->pendingParamCBs |= MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS; - } -} - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief Handles a noise histogram timer expiry, by requesting noise histogram - * reaults from the FW.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param requestIndex - index of the beacon request in the request structure.\n - */ -void measurementSRVHandleNoiseHistogramComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TTwdParamInfo tTwdParam; - TNoiseHistogram pNoiseHistParams; - TI_STATUS status; - - /* Set Noise Histogram Cmd Params */ - pNoiseHistParams.cmd = STOP_NOISE_HIST; - pNoiseHistParams.sampleInterval = 0; - os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[0]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES ); - - /* Send a Stop command to the FW */ - status = cmdBld_CmdNoiseHistogram (pMeasurementSRV->hCmdBld, &pNoiseHistParams, NULL, NULL); - - if ( TI_OK != status ) - { -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": whalCtrl_NoiseHistogramCmd returned status %d\n", status); - - /* mark that the specific measurment type has failed */ - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; - - /* if all measurement types has finished, an event will be send by request timer expired */ - } - - /* Get measurement results */ - tTwdParam.paramType = TWD_NOISE_HISTOGRAM_PARAM_ID; - tTwdParam.content.interogateCmdCBParams.fCb = (void *)MacServices_measurementSRV_noiseHistCallBack; - tTwdParam.content.interogateCmdCBParams.hCb = hMeasurementSRV; - tTwdParam.content.interogateCmdCBParams.pCb = (TI_UINT8*)&pMeasurementSRV->noiseHistogramResults; - status = cmdBld_GetParam (pMeasurementSRV->hCmdBld, &tTwdParam); - - if ( TI_OK == status ) - { - /* setting On the Waitng for Noise Histogram Results Bit */ - pMeasurementSRV->pendingParamCBs |= MSR_SRV_WAITING_NOISE_HIST_RESULTS; - -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": sent noise histogram stop command.\n"); - } - else - { -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": whalCtrl_GetParam returned status %d\n", status); - - /* mark that the specific measurment type has failed */ - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; - - /* if all measurement types has finished, an event will be send by request timer expired */ - } -} - -/** - * \author Ronen Kalish\n - * \date 16-November-2005\n - * \brief Callback for channel load get param call.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param status - the get_param call status.\n - * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) - */ -void MacServices_measurementSRV_channelLoadParamCB( TI_HANDLE hMeasurementSRV, TI_STATUS status, - TI_UINT8* CB_buf ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_UINT32 mediumUsageInMs, periodInMs; - TI_INT32 requestIndex; - - /* when this CB is called as a result of the nulify call at the measurement beginning, - the handle will be NULL. In this case, nothing needs to be done. */ - if ( NULL == hMeasurementSRV ) - { - return; - } - -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Channel load CB called, status:%d\n", status); -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "result address (reported): 0x%x, result address (assumed): 0x%x, results (reported):\n", CB_buf, &(pMeasurementSRV->mediumOccupancyResults)); - TRACE_INFO_HEX( pMeasurementSRV->hReport, CB_buf, sizeof(TMediumOccupancy)); - - /* setting Off the Waitng for Channel Load Results Bit */ - pMeasurementSRV->pendingParamCBs &= ~MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS; - - /* find the request index */ - requestIndex = measurementSRVFindIndexByType( hMeasurementSRV, MSR_TYPE_CCA_LOAD_MEASUREMENT ); - if ( -1 == requestIndex ) - { - /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request index from measurementSRVFindIndexByType is -1?!?"); - return; - } - - if ( (TI_OK == status) && (0 != pMeasurementSRV->mediumOccupancyResults.Period)) - { - /* calculate results */ - mediumUsageInMs = pMeasurementSRV->mediumOccupancyResults.MediumUsage / 1000; - periodInMs = pMeasurementSRV->mediumOccupancyResults.Period / 1000; - -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": MediumUsage = %d Period = %d\n",mediumUsageInMs, periodInMs); - - if ( periodInMs <= pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration ) - { - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.CCABusyFraction = - ( 255 * pMeasurementSRV->mediumOccupancyResults.MediumUsage ) / - pMeasurementSRV->mediumOccupancyResults.Period; - } - else - { - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.CCABusyFraction = - ( 255 * pMeasurementSRV->mediumOccupancyResults.MediumUsage ) / - (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration * 1000); - } - } - else - { -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": channel load failed. Status=%d, period=%d\n", status, pMeasurementSRV->mediumOccupancyResults.Period); - - /* mark result status */ - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; - } - - /* if no measurement are running and no CBs are pending, - send ALL TYPES COMPLETE event */ - if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) - { - /* send the event */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); - } -} - -/** - * \date 03-January-2005\n - * \brief Dummy callback for channel load get param call. Used to clear the channel load tracker.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param status - the get_param call status.\n - * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) - */ -void MacServices_measurementSRV_dummyChannelLoadParamCB( TI_HANDLE hMeasurementSRV, TI_STATUS status, - TI_UINT8* CB_buf ) -{ -#ifdef TI_DBG - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*) hMeasurementSRV; - -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Dummy Channel Load callback called (status = %d)\n", status); -#endif /* TI_DBG */ -} - -/** - * \author Ronen Kalish\n - * \date 16-November-2005\n - * \brief Callback for noise histogram get param call.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param status - the get_param call status.\n - * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) - */ -void MacServices_measurementSRV_noiseHistCallBack( TI_HANDLE hMeasurementSRV, TI_STATUS status, - TI_UINT8* CB_buf ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_UINT8 index; - TI_UINT32 sumOfSamples; - TI_INT32 requestIndex; - -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": noise histogram CB called, status: %d\n", status); -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "result address (reported): 0x%x, result address (assumed): 0x%x, results (reported):\n", CB_buf, &(pMeasurementSRV->noiseHistogramResults)); - TRACE_INFO_HEX( pMeasurementSRV->hReport, CB_buf, sizeof(TNoiseHistogramResults)); - - /* setting Off the Waitng for noise histogram Results Bit */ - pMeasurementSRV->pendingParamCBs &= ~MSR_SRV_WAITING_NOISE_HIST_RESULTS; - - /* find the request index */ - requestIndex = measurementSRVFindIndexByType( hMeasurementSRV, MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT ); - if ( -1 == requestIndex ) - { - /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request index from measurementSRVFindIndexByType is -1?!?"); - return; - } - - if ( TI_OK == status ) - { - sumOfSamples = pMeasurementSRV->noiseHistogramResults.numOfLostCycles; - - /* Print For Debug */ -TRACE4( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": numOfLostCycles = %d numOfTxHwGenLostCycles = %d numOfRxLostCycles = %d numOfExceedLastThresholdLostCycles = %d\n", pMeasurementSRV->noiseHistogramResults.numOfLostCycles, pMeasurementSRV->noiseHistogramResults.numOfTxHwGenLostCycles, pMeasurementSRV->noiseHistogramResults.numOfRxLostCycles, pMeasurementSRV->noiseHistogramResults.numOfLostCycles - (pMeasurementSRV->noiseHistogramResults.numOfTxHwGenLostCycles + pMeasurementSRV->noiseHistogramResults.numOfRxLostCycles)); - - for ( index = 0; index < NUM_OF_NOISE_HISTOGRAM_COUNTERS; index++ ) - { - sumOfSamples += pMeasurementSRV->noiseHistogramResults.counters[ index ]; - - /* Print For Debug */ -TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Counter #%d = %x\n", index, pMeasurementSRV->noiseHistogramResults.counters[index]); - } - - /* If there weren't enough samples --> Reject the Request */ - if ( (sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles) < - NOISE_HISTOGRAM_THRESHOLD ) - { -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_WARNING, ": noise histogram CB, rejecting request because %d samples received.\n", sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles); - - /* set negative result status */ - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; - } - else - { - for (index = 0; index < NUM_OF_NOISE_HISTOGRAM_COUNTERS; index++) - { - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ index ] = - ( 255 * pMeasurementSRV->noiseHistogramResults.counters[ index ]) / sumOfSamples; - } - -TRACE8( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Valid noise histogram reply. RPIDensity: %d %d %d %d %d %d %d %d\n", pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 0 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 1 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 2 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 3 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 4 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 5 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 6 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 7 ]); - } - } - else - { -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_WARNING, ": noise histogram CB with status: %d, rejecting request.\n", status); - /* set negative result status */ - pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; - } - - /* if no measurement are running and no CBs are pending, - send ALL TYPES COMPLETE event */ - if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) - { - /* send the event */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); - } -} - -/** - * \author Ronen Kalish\n - * \date 16-November-2005\n - * \brief Checks whether all measuremtn types had completed and all param CBs had been called.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param status - the get_param call status.\n - * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) - */ -TI_BOOL measurementSRVIsMeasurementComplete( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - - /* verify that no request is currently running */ - for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) - { - if ( TI_TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] ) - { - return TI_FALSE; - } - } - - /* verify that no CBs are pending */ - if ( 0 != (pMeasurementSRV->pendingParamCBs & - (MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS | MSR_SRV_WAITING_NOISE_HIST_RESULTS))) - { - return TI_FALSE; - } - - return TI_TRUE; -} - -/** - * \author Ronen Kalish\n - * \date 17-November-2005\n - * \brief Finds a measure type index in the measure request array.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param type - the measure type to look for.\n - * \return the type index, -1 if not found.\n - */ -TI_INT32 measurementSRVFindIndexByType( TI_HANDLE hMeasurementSRV, EMeasurementType type ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - - for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) - { - if ( type == pMeasurementSRV->msrRequest.msrTypes[ i ].msrType ) - { - return i; - } - } - return -1; -} - - - -/**************************************************************************************** - * measurementSRVRegisterFailureEventCB * - **************************************************************************************** -DESCRIPTION: Registers a failure event callback for scan error notifications. - - -INPUT: - hMeasurementSRV - handle to the Measurement SRV object. - - failureEventCB - the failure event callback function.\n - - hFailureEventObj - handle to the object passed to the failure event callback function. - -OUTPUT: -RETURN: void. -****************************************************************************************/ - -void measurementSRVRegisterFailureEventCB( TI_HANDLE hMeasurementSRV, - void * failureEventCB, TI_HANDLE hFailureEventObj ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - - pMeasurementSRV->failureEventFunc = (TFailureEventCb)failureEventCB; - pMeasurementSRV->failureEventObj = hFailureEventObj; -} - - diff --git a/wl1271/TWD/MacServices/MeasurementSrv.h b/wl1271/TWD/MacServices/MeasurementSrv.h deleted file mode 100644 index 7a852f4e..00000000 --- a/wl1271/TWD/MacServices/MeasurementSrv.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - * MeasurementSrv.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file MeasurementSrv.h - * \brief This file include private definitions for the Measurement SRV module. - * \author Ronen Kalish - * \date 08-November-2005 - */ - -#ifndef __MEASUREMENT_SRV_H__ -#define __MEASUREMENT_SRV_H__ - -#include "TWDriverInternal.h" -#include "MacServices_api.h" -#include "fsm.h" -#include "MeasurementSrvSM.h" - -/* - *********************************************************************** - * Constant definitions. - *********************************************************************** - */ -/* Time in milliseconds to receive a command complete for measure start / stop from the FW */ -#define MSR_FW_GUARD_TIME 100 -#define DEF_SAMPLE_INTERVAL (100) /* expressed in microsec */ -#define NOISE_HISTOGRAM_THRESHOLD 100 -/* Get param callback flags */ -#define MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS 0x01 /* channel load results are still pending */ -#define MSR_SRV_WAITING_NOISE_HIST_RESULTS 0x02 /* noise histogram results are still pending */ - -/* - *********************************************************************** - * Enums. - *********************************************************************** - */ - - -/* - *********************************************************************** - * Typedefs. - *********************************************************************** - */ - -/* - *********************************************************************** - * Structure definitions. - *********************************************************************** - */ - -/** \struct measurementSRV_t - * \brief This structure contains the measurement SRV object data - */ -typedef struct -{ - TMediumOccupancy mediumOccupancyResults; /**< channel load results buffer */ - TNoiseHistogramResults noiseHistogramResults; /**< noise histogram results buffer */ - - /* module handles */ - TI_HANDLE hOS; /**< OS object handle */ - TI_HANDLE hReport; /**< report object handle */ - TI_HANDLE hPowerSaveSRV; /**< power save SRV object handle */ - TI_HANDLE hCmdBld; /**< Command Builder object handle */ - TI_HANDLE hEventMbox; /**< Event Mbox handle */ - TI_HANDLE hTimer ; /**< Timer Module handle */ - /* CB functions and objects */ - TMeasurementSrvCompleteCb measurmentCompleteCBFunc; - /**< - * upper layer (measurement manager) measurement complete - * callback function - */ - TI_HANDLE measurementCompleteCBObj; /**< - * upper layer (measurement manager) measurement complete - * callback object - */ - - TCmdResponseCb commandResponseCBFunc; /**< - * upper layer command response CB, used for both start - * and stop. Passed down to the HAL and called when - * the measurement command has been received by the FW - */ - TI_HANDLE commandResponseCBObj; /**< - * object parameter passed to the commandResposeFunc by - * the HAL when it is called - */ - - TFailureEventCb failureEventFunc; /**< - * upper layer Failure Event CB. - * called when the scan command has been Timer Expiry - */ - TI_HANDLE failureEventObj; /**< - * object parameter passed to the failureEventFunc - * when it is called - */ - /* Timers */ - TI_HANDLE hRequestTimer[ MAX_NUM_OF_MSR_TYPES_IN_PARALLEL ]; - /**< Timers for different measurement types */ - TI_BOOL bRequestTimerRunning[ MAX_NUM_OF_MSR_TYPES_IN_PARALLEL ]; - /**< Indicates whether each request timer is running */ - TI_HANDLE hStartStopTimer; /**< Timer for start / stop commands guard */ - TI_BOOL bStartStopTimerRunning; /**< - * Indicates whether the start / stop command guard - * timer is running - */ - /* Misc stuff */ - TI_BOOL bInRequest; /**< - * Indicates whether the SM is run within - * the measurement request context (if so, to avoid - * re-entrance, the complete function shouldn't - * be called on failure, but rather an invalid - * status should be returned) - */ - TI_STATUS returnStatus; /**< - * Holds the return code to the upper layer - * Used to save errors during SM operation. - */ - TI_BOOL bSendNullDataWhenExitPs; /**< whether to send NULL data frame when exiting - * driver mode - */ - /* state machine */ - fsm_stateMachine_t* SM; /**< - * state machines for different - * scan types - */ - measurements_SRVSMStates_e SMState; /**< state machine current states */ - /* measurement request */ - TMeasurementRequest msrRequest; /**< measurement request parameters */ - TMeasurementReply msrReply; /**< measurement reply values */ - TI_UINT32 requestRecptionTimeStampMs; /**< The time in which the request was received. */ - TI_UINT32 timeToRequestExpiryMs; /**< - * The duration (in ms) from request receiption - * until it should actually start. Request is - * discarded if a longer period is required - */ - TI_UINT8 pendingParamCBs; /**< - * a bitmap indicating which get_param CBs are - * currently pending (noise histogram and/or - * channel load). - */ -} measurementSRV_t; - -/* - *********************************************************************** - * External data definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External functions definitions - *********************************************************************** - */ - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Creates the measurement SRV object - * - * Function Scope \e Public.\n - * \param hOS - handle to the OS object.\n - * \return a handle to the measurement SRV object, NULL if an error occurred.\n - */ -TI_HANDLE MacServices_measurementSRV_create( TI_HANDLE hOS ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Initializes the measurement SRV object - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param hReport - handle to the report object.\n - * \param hCmdBld - handle to the Command Builder object.\n - * \param hEventMbox - handle to the Event Mbox object.\n - * \param hPowerSaveSRV - handle to the power save SRV object.\n - * \param hTimer - handle to the Timer module object.\n - */ -TI_STATUS MacServices_measurementSRV_init (TI_HANDLE hMeasurementSRV, - TI_HANDLE hReport, - TI_HANDLE hCmdBld, - TI_HANDLE hEventMbox, - TI_HANDLE hPowerSaveSRV, - TI_HANDLE hTimer); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Destroys the measurement SRV object - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - */ -void MacServices_measurementSRV_destroy( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 13-November-2005\n - * \brief Checks whether a beacon measurement is part of current measurement request - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \return TI_TRUE if a beacon measurement is part of current request, TI_FALSE otherwise.\n - */ -TI_BOOL measurementSRVIsBeaconMeasureIncluded( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief Finds the index for the measurement request with the shortest period - * (the one that has now completed).\n - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \return index of the measurement request with the shortest duration.\n - */ -TI_INT32 measurementSRVFindMinDuration( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief Handles an AP discovery timer expiry, by setting necessary values in the - * reply struct.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param requestIndex - index of the beacon request in the request structure.\n - */ -void measurementSRVHandleBeaconMsrComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ); - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief Handles a channel load timer expiry, by requesting channel load - * results from the FW.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param requestIndex - index of the channel load request in the request structure.\n - */ -void measurementSRVHandleChannelLoadComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ); - -/** - * \author Ronen Kalish\n - * \date 15-November-2005\n - * \brief Handles a nois histogram timer expiry, by requesting noise histogram - * reaults from the FW.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param requestIndex - indexof the beacon request in the request structure.\n - */ -void measurementSRVHandleNoiseHistogramComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ); - -/** - * \author Ronen Kalish\n - * \date 16-November-2005\n - * \brief Checks whether all measuremtn types had completed and all param CBs had been called.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param status - the get_param call status.\n - * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) - */ -TI_BOOL measurementSRVIsMeasurementComplete( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 17-November-2005\n - * \brief Finds a measure type index in the measure request array.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param type - the measure type to look for.\n - * \return the type index, -1 if not found.\n - */ -TI_INT32 measurementSRVFindIndexByType( TI_HANDLE hMeasurementSRV, EMeasurementType type ); - -/**************************************************************************************** - * measurementSRVRegisterFailureEventCB * - **************************************************************************************** -DESCRIPTION: Registers a failure event callback for scan error notifications. - - -INPUT: - hMeasurementSRV - handle to the Measurement SRV object. - - failureEventCB - the failure event callback function.\n - - hFailureEventObj - handle to the object passed to the failure event callback function. - -OUTPUT: -RETURN: void. -****************************************************************************************/ -void measurementSRVRegisterFailureEventCB( TI_HANDLE hMeasurementSRV, - void * failureEventCB, TI_HANDLE hFailureEventObj ); - -void measurementSRV_restart( TI_HANDLE hMeasurementSRV); - - -#endif /* __MEASUREMENT_SRV_H__ */ - diff --git a/wl1271/TWD/MacServices/MeasurementSrvSM.c b/wl1271/TWD/MacServices/MeasurementSrvSM.c deleted file mode 100644 index e81d41d7..00000000 --- a/wl1271/TWD/MacServices/MeasurementSrvSM.c +++ /dev/null @@ -1,1063 +0,0 @@ -/* - * MeasurementSrvSM.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file measurementSrv.c - * \brief This file include the measurement SRV state machine implementation. - * \author Ronen Kalish - * \date 13-November-2005 - */ - -#define __FILE_ID__ FILE_ID_112 -#include "osApi.h" -#include "report.h" -#include "MeasurementSrvSM.h" -#include "MeasurementSrv.h" -#include "PowerSrv_API.h" -#include "timer.h" -#include "fsm.h" -#include "TWDriverInternal.h" -#include "CmdBld.h" - - -TI_STATUS actionUnexpected( TI_HANDLE hMeasurementSrv ); -TI_STATUS actionNop( TI_HANDLE hMeasurementSrv ); -static void measurementSRVSM_requestMeasureStartResponseCB(TI_HANDLE hMeasurementSRV, TI_UINT32 uMboxStatus); - - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Initialize the measurement SRV SM.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS measurementSRVSM_init( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - - fsm_actionCell_t smMatrix[ MSR_SRV_NUM_OF_STATES ][ MSR_SRV_NUM_OF_EVENTS ] = - { - /* next state and actions for IDLE state */ - { - {MSR_SRV_STATE_WAIT_FOR_DRIVER_MODE, measurementSRVSM_requestDriverMode}, /*"MESSURE_START_REQUEST"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/ - {MSR_SRV_STATE_IDLE, measurementSRVSRVSM_dummyStop} /*"MEASURE_STOP_REQUEST"*/ - }, - - - /* next state and actions for WAIT_FOR_DRIVER_MODE state */ - { - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/ - {MSR_SRV_STATE_WAIT_FOR_MEASURE_START, measurementSRVSM_requestMeasureStart}, /*"DRIVER_MODE_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, measurementSRVSM_DriverModeFailure}, /*"DRIVER_MODE_FAILURE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/ - {MSR_SRV_STATE_IDLE, measurementSRVSM_stopFromWaitForDriverMode} /*"MEASURE_STOP_REQUEST"*/ - }, - - /* next state and actions for WAIT_FOR_MEASURE_START state */ - { - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/ - {MSR_SRV_STATE_MEASURE_IN_PROGRESS, measurementSRVSM_startMeasureTypes}, /*"START_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, measurementSRVSM_measureStartFailure}, /*"START_FAILURE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/ - {MSR_SRV_STATE_IDLE, measurementSRVSM_completeMeasure}, /*"STOP_COMPLETE"*/ - {MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_stopFromWaitForMeasureStart} - /*"MEASURE_STOP_REQUEST"*/ - }, - - /* next state and actions for MEASURE_IN_PROGRESS state */ - { - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/ - {MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_requestMeasureStop}, /*"ALL_TYPES_COMPLETE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/ - {MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_stopFromMeasureInProgress} - /*"MEASURE_STOP_REQUEST"*/ - }, - - /* next state and actions for WAIT_FOR_MEASURE_STOP state */ - { - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/ - {MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/ - {MSR_SRV_STATE_IDLE, measurementSRVSM_completeMeasure}, /*"STOP_COMPLETE"*/ - {MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSRVSM_dummyStop} /*"MEASURE_STOP_REQUEST"*/ - } - }; - - /* initialize current state */ - pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE; - - /* configure the state machine */ - return fsm_Config( pMeasurementSRV->SM, (fsm_Matrix_t)smMatrix, - (TI_UINT8)MSR_SRV_NUM_OF_STATES, (TI_UINT8)MSR_SRV_NUM_OF_EVENTS, - (fsm_eventActivation_t)measurementSRVSM_SMEvent, pMeasurementSRV->hOS ); -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Processes an event.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the measurement SRV object.\n - * \param currentState - the current scan SRV SM state.\n - * \param event - the event to handle.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS measurementSRVSM_SMEvent( TI_HANDLE hMeasurementSrv, measurements_SRVSMStates_e* currentState, - measurement_SRVSMEvents_e event ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t *)hMeasurementSrv; - TI_STATUS status = TI_OK; - TI_UINT8 nextState; - - /* obtain the next state */ - status = fsm_GetNextState( pMeasurementSRV->SM, (TI_UINT8)*currentState, (TI_UINT8)event, &nextState ); - if ( status != TI_OK ) - { - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "measurementSRVSM_SMEvent: State machine error, failed getting next state\n"); - return TI_NOK; - } - - /* report the move */ - TRACE3( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "measurementSRVSM_SMEvent: <currentState = %d, event = %d> --> nextState = %d\n", currentState, event, nextState); - - /* move */ - return fsm_Event( pMeasurementSRV->SM, (TI_UINT8*)currentState, (TI_UINT8)event, hMeasurementSrv ); -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a MEASURE_START_REQUEST event by requesting driver mode.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_requestDriverMode( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_STATUS PSStatus; - TTwdParamInfo paramInfo; - - /* get the current channel */ - paramInfo.paramType = TWD_CURRENT_CHANNEL_PARAM_ID; - cmdBld_GetParam (pMeasurementSRV->hCmdBld, ¶mInfo); - - /* check if the request is on the serving channel */ - if ( paramInfo.content.halCtrlCurrentChannel == pMeasurementSRV->msrRequest.channel ) - { - /* Switch Power Save SRV to driver mode w/o changing power save mode*/ - PSStatus = powerSrv_ReservePS( pMeasurementSRV->hPowerSaveSRV, POWER_SAVE_KEEP_CURRENT, - TI_TRUE, hMeasurementSRV, MacServices_measurementSRV_powerSaveCB ); - } - else - { - /* Switch Power Save SRV to driver mode with PS mode */ - PSStatus = powerSrv_ReservePS( pMeasurementSRV->hPowerSaveSRV, POWER_SAVE_ON, - TI_TRUE, hMeasurementSRV, MacServices_measurementSRV_powerSaveCB ); - } - - switch (PSStatus) - { - case POWER_SAVE_802_11_IS_CURRENT: - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Driver mode entered successfully\n"); - /* send a power save success event */ - return measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_DRIVER_MODE_SUCCESS ); - - case POWER_SAVE_802_11_PENDING: - case TI_OK: - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Driver mode pending\n"); - break; - - default: /* Error */ - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Error %d when requesting driver mode\n",PSStatus); - - /* Set the return status to TI_NOK */ - pMeasurementSRV->returnStatus = PSStatus; - - /* send a power save failure event */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_DRIVER_MODE_FAILURE ); - break; - } - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a DRIVER_MODE_SUCCESS event by sending start measure command to the FW.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_requestMeasureStart( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TMeasurementParams pMeasurementCmd; - TI_STATUS status; - TI_UINT32 currentTime = os_timeStampMs( pMeasurementSRV->hOS ); - - /* check if request time has expired (note: timer wrap-around is also handled)*/ - if ( (pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs) - < currentTime ) - { - TI_INT32 i; - - TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request time has expired, request expiry time:%d, current time:%d\n", pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs, currentTime); - - /* mark that all measurement types has failed */ - for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) - { - pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK; - } - - /* send a measurement complete event */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_STOP_COMPLETE ); - - return TI_OK; - } - - pMeasurementCmd.channel = pMeasurementSRV->msrRequest.channel; - pMeasurementCmd.band = pMeasurementSRV->msrRequest.band; - pMeasurementCmd.duration = 0; /* Infinite */ - pMeasurementCmd.eTag = pMeasurementSRV->msrRequest.eTag; - - if ( measurementSRVIsBeaconMeasureIncluded( hMeasurementSRV )) - { /* Beacon Measurement is one of the types */ - - /* get the current channel */ - TTwdParamInfo paramInfo; - - paramInfo.paramType = TWD_CURRENT_CHANNEL_PARAM_ID; - cmdBld_GetParam (pMeasurementSRV->hCmdBld, ¶mInfo); - - pMeasurementCmd.ConfigOptions = RX_CONFIG_OPTION_FOR_MEASUREMENT; - - /* check if the request is on the serving channel */ - if ( paramInfo.content.halCtrlCurrentChannel == pMeasurementSRV->msrRequest.channel ) - { - /* Set the RX Filter to the join one, so that any packets will - be received on the serving channel - beacons and probe requests for - the measurmenet, and also data (for normal operation) */ - pMeasurementCmd.FilterOptions = RX_FILTER_OPTION_JOIN; - } - else - { - /* not on the serving channle - only beacons and rpobe responses are required */ - pMeasurementCmd.FilterOptions = RX_FILTER_OPTION_DEF_PRSP_BCN; - } - } - else - { /* No beacon measurement - use the current RX Filter */ - pMeasurementCmd.ConfigOptions = 0xffffffff; - pMeasurementCmd.FilterOptions = 0xffffffff; - } - - /* Send start measurement command */ - status = cmdBld_CmdMeasurement (pMeasurementSRV->hCmdBld, - &pMeasurementCmd, - (void *)measurementSRVSM_requestMeasureStartResponseCB, - pMeasurementSRV); - - if ( TI_OK != status ) - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Failed to send measurement start command, statud=%d,\n", status); - - /* keep the faulty return status */ - pMeasurementSRV->returnStatus = status; - - /* send a measurement start fail event */ - return measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_START_FAILURE ); - } - - TRACE6( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure start command sent. Params:\n channel=%d, band=%d, duration=%d, \n configOptions=0x%x, filterOptions=0x%x, status=%d, \n", pMeasurementCmd.channel, pMeasurementCmd.band, pMeasurementCmd.duration, pMeasurementCmd.ConfigOptions, pMeasurementCmd.FilterOptions, status); - - /* start the FW guard timer */ - pMeasurementSRV->bStartStopTimerRunning = TI_TRUE; - tmr_StartTimer (pMeasurementSRV->hStartStopTimer, - MacServices_measurementSRV_startStopTimerExpired, - (TI_HANDLE)pMeasurementSRV, - MSR_FW_GUARD_TIME, - TI_FALSE); - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a START_SUCCESS event by starting different measure types and setting timers.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_startMeasureTypes( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_UINT8 requestIndex, rangeIndex; - TI_INT8 rangeUpperBound; - TTwdParamInfo tTwdParam; - TI_STATUS status; - TNoiseHistogram pNoiseHistParams; - TApDiscoveryParams pApDiscoveryParams; - TI_UINT32 currentTime = os_timeStampMs( pMeasurementSRV->hOS ); - - /* check if request time has expired (note: timer wrap-around is also handled)*/ - if ( (pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs) - < currentTime ) - { - TI_INT32 i; - - TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request time has expired, request expiry time:%d, current time:%d\n", pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs, currentTime); - - /* mark that all measurement types has failed */ - for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) - { - pMeasurementSRV->msrReply.msrTypes[ i ].status = MSR_REJECT_MAX_DELAY_PASSED; - } - - /* send a measurement complete event */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); - - return TI_OK; - } - - /* Going over all request types that should be executed in parallel - to start their timers and execute the measurement */ - for ( requestIndex = 0; requestIndex < pMeasurementSRV->msrRequest.numberOfTypes ; requestIndex++ ) - { - switch (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType) - { - case MSR_TYPE_CCA_LOAD_MEASUREMENT: - /* Clearing the Medium Occupancy Register */ - tTwdParam.paramType = TWD_MEDIUM_OCCUPANCY_PARAM_ID; - tTwdParam.content.interogateCmdCBParams.fCb = (void *)MacServices_measurementSRV_dummyChannelLoadParamCB; - tTwdParam.content.interogateCmdCBParams.hCb = hMeasurementSRV; - tTwdParam.content.interogateCmdCBParams.pCb = - (TI_UINT8*)&pMeasurementSRV->mediumOccupancyResults; - status = cmdBld_GetParam (pMeasurementSRV->hCmdBld, &tTwdParam); - if( TI_OK == status ) - { - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Medium Usage has been nullified, starting timer.\n"); - - /* Start Timer */ - tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex], - MacServices_measurementSRV_requestTimerExpired, - (TI_HANDLE)pMeasurementSRV, - pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration, - TI_FALSE); - pMeasurementSRV->bRequestTimerRunning[requestIndex] = TI_TRUE; - } - else - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_GetParam (for channel load) returned status %d\n", status); - } - - break; - - case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT: - /* Set Noise Histogram Cmd Params */ - pNoiseHistParams.cmd = START_NOISE_HIST; - pNoiseHistParams.sampleInterval = DEF_SAMPLE_INTERVAL; - os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[0]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES ); - - /* Set Ranges */ - /* (-87) - First Range's Upper Bound */ - rangeUpperBound = -87; - - /* Previously we converted from RxLevel to dBm - now this isn't necessary */ - /* rangeUpperBound = TWD_convertRSSIToRxLevel( pMeasurementSRV->hTWD, -87); */ - - for(rangeIndex = 0; rangeIndex < MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES -1; rangeIndex++) - { - if(rangeUpperBound > 0) - { - pNoiseHistParams.ranges[rangeIndex] = 0; - } - else - { - pNoiseHistParams.ranges[rangeIndex] = rangeUpperBound; - } - rangeUpperBound += 5; - } - pNoiseHistParams.ranges[rangeIndex] = 0xFE; - - /* Print for Debug */ - TRACE8(pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ":Noise histogram Measurement Ranges:\n%d %d %d %d %d %d %d %d\n", (TI_INT8) pNoiseHistParams.ranges[0], (TI_INT8) pNoiseHistParams.ranges[1], (TI_INT8) pNoiseHistParams.ranges[2], (TI_INT8) pNoiseHistParams.ranges[3], (TI_INT8) pNoiseHistParams.ranges[4], (TI_INT8) pNoiseHistParams.ranges[5], (TI_INT8) pNoiseHistParams.ranges[6], (TI_INT8) pNoiseHistParams.ranges[7]); - - /* Send a Start command to the FW */ - status = cmdBld_CmdNoiseHistogram (pMeasurementSRV->hCmdBld, &pNoiseHistParams, NULL, NULL); - - if ( TI_OK == status ) - { - /* Print for Debug */ - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Sent noise histogram command. Starting timer\n"); - - /* Start Timer */ - tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex], - MacServices_measurementSRV_requestTimerExpired, - (TI_HANDLE)pMeasurementSRV, - pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration, - TI_FALSE); - pMeasurementSRV->bRequestTimerRunning[requestIndex] = TI_TRUE; - } - else - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_NoiseHistogramCmd returned status %d\n", status); - } - break; - - case MSR_TYPE_BEACON_MEASUREMENT: - /* set all parameters in the AP discovery command */ - pApDiscoveryParams.scanDuration = pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration * 1000; /* TODO change this to an infinite value (was 0) */ - pApDiscoveryParams.numOfProbRqst = 1; - pApDiscoveryParams.txdRateSet = HW_BIT_RATE_1MBPS; - pApDiscoveryParams.ConfigOptions = RX_CONFIG_OPTION_FOR_MEASUREMENT; - pApDiscoveryParams.FilterOptions = RX_FILTER_OPTION_DEF_PRSP_BCN; - pApDiscoveryParams.txPowerDbm = pMeasurementSRV->msrRequest.txPowerDbm; - pApDiscoveryParams.scanOptions = SCAN_ACTIVE; /* both scan type and band are 0 for active and */ - /* 2.4 GHz, respectively, but 2.4 is not defined */ - - /* band determined at the initiate measurement command not at that structure */ - - /* scan mode go into the scan option field */ - if ( MSR_SCAN_MODE_PASSIVE == pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].scanMode ) - { - pApDiscoveryParams.scanOptions |= SCAN_PASSIVE; - } - - /* Send AP Discovery command */ - status = cmdBld_CmdApDiscovery (pMeasurementSRV->hCmdBld, &pApDiscoveryParams, NULL, NULL); - - if ( TI_OK == status ) - { - TRACE7( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": AP discovery command sent. Params:\n scanDuration=%d, scanOptions=%d, numOfProbRqst=%d, txdRateSet=%d, txPowerDbm=%d, configOptions=%d, filterOptions=%d\n Starting timer...\n", pApDiscoveryParams.scanDuration, pApDiscoveryParams.scanOptions, pApDiscoveryParams.numOfProbRqst, pApDiscoveryParams.txdRateSet, pApDiscoveryParams.txPowerDbm, pApDiscoveryParams.ConfigOptions, pApDiscoveryParams.FilterOptions); - - /* Start Timer */ - tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex], - MacServices_measurementSRV_requestTimerExpired, - (TI_HANDLE)pMeasurementSRV, - pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration, - TI_FALSE); - pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TI_TRUE; - } - else - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_ApDiscoveryCmd returned status %d\n", status); - } - break; - - case MSR_TYPE_BASIC_MEASUREMENT: /* not supported in current implemntation */ - case MSR_TYPE_FRAME_MEASUREMENT: /* not supported in current implemntation */ - default: - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Measurement type %d is not supported\n", pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType); - break; - } - } - - /* if no measurement types are running, sen al types complete event. - This can happen if all types failed to start */ - if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) - { - /* send the event */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); - } - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle an ALL_TYPE_COMPLETE event by sending a stop measure command to the FW.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_requestMeasureStop( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_STATUS status; - - /* since this function may also be called when stop is requested and start complete event - has not yet been received from the FW, we may need to stop the FW guard timer */ - if (pMeasurementSRV->bStartStopTimerRunning) - { - tmr_StopTimer (pMeasurementSRV->hStartStopTimer); - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - } - - /* Send Measurement Stop command to the FW */ - status = cmdBld_CmdMeasurementStop (pMeasurementSRV->hCmdBld, - (void *)pMeasurementSRV->commandResponseCBFunc, - pMeasurementSRV->commandResponseCBObj); - - pMeasurementSRV->commandResponseCBFunc = NULL; - pMeasurementSRV->commandResponseCBObj = NULL; - - if ( TI_OK != status ) - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Failed to send measurement stop command, statud=%d,\n", status); - - /* send a measurement complete event - since it can't be stopped */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_STOP_COMPLETE ); - return TI_OK; - } - - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure stop command sent.\n"); - - /* start the FW guard timer */ - pMeasurementSRV->bStartStopTimerRunning = TI_TRUE; - tmr_StartTimer (pMeasurementSRV->hStartStopTimer, - MacServices_measurementSRV_startStopTimerExpired, - (TI_HANDLE)pMeasurementSRV, - MSR_FW_GUARD_TIME, - TI_FALSE); - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a STOP_COMPLETE event by exiting driver mode and calling the complete CB.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_completeMeasure( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t *)hMeasurementSRV; - - /* Switch Power Save SRV back to user mode */ - powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL ); - - /* if the response CB is still pending, call it (when requestExpiryTimeStamp was reached) */ - if ( NULL != pMeasurementSRV->commandResponseCBFunc ) - { - pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_OK ); - } - - /* call the complete CB */ - if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc ) - { - pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, - &(pMeasurementSRV->msrReply)); - } - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE state by exiting driver mode. - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_stopFromWaitForDriverMode( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - - /* Switch Power Save SRV back to user mode */ - powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL ); - - /* if we are not running within a stop request context (shouldn't happen), call the CBs */ - if ( TI_FALSE == pMeasurementSRV->bInRequest ) - { - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": stop from wait for driver mode: not within a request context?!? \n"); - - /* call the response CB - this shouldn't happen, as only GWSI has response CB, and it shouldn't call - stop before driver */ - if ( NULL != pMeasurementSRV->commandResponseCBFunc ) - { - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": stop from wait for driver mode: command response CB is not NULL?!? \n"); - pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_OK ); - - pMeasurementSRV->commandResponseCBFunc = NULL; - pMeasurementSRV->commandResponseCBObj = NULL; - } - /* call the complete CB */ - if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc ) - { - /* mark that all types has failed */ - TI_INT32 i; - for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) - { - pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK; - } - /* call the complete CB */ - pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, - &(pMeasurementSRV->msrReply)); - } - else - { - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": stop from wait for driver mode and response CB is NULL!!!\n"); - } - } - /* we are within a stop request context */ - else - { - /* if the command response Cb is valid, send a measure stop command to the FW - - although it is not necessary, we need it to get a different context for the command response. - This shouldn't happen, as only GWSI has command response, and it shouldn't call stop measure - before it got the commadn response for start measure */ - if ( NULL != pMeasurementSRV->commandResponseCBFunc ) - { - /* shouldn't happen - a command response is valid (GWSI) and stop measure called - before measure start response was received (driver) */ - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": stop from wait for driver mode - within request context and command response is not NULL?!?\n"); - - cmdBld_CmdMeasurementStop (pMeasurementSRV->hCmdBld, - (void *)pMeasurementSRV->commandResponseCBFunc, - pMeasurementSRV->commandResponseCBObj); - - pMeasurementSRV->commandResponseCBFunc = NULL; - pMeasurementSRV->commandResponseCBObj = NULL; - } - if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc ) - { - /* Note: this is being called from request context, but there's npthing else that can be done */ - /* mark that all types has failed */ - TI_INT32 i; - for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) - { - pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK; - } - /* call the complete CB */ - pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, - &(pMeasurementSRV->msrReply)); - } - } - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 27-November-2005\n - * \brief handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE by marking negative result status - * \brief and calling the ordinary stop function - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_stopFromWaitForMeasureStart( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - - /* mark that all types has failed */ - for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) - { - pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK; - } - - /* call the ordinary stop function (will send a measure stop command to FW) */ - measurementSRVSM_requestMeasureStop( hMeasurementSRV ); - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief handle a STOP_REQUEST event when in MEASURE_IN_PROGRESS by stopping all measure types and - * \brief requesting measure stop from the FW.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_stopFromMeasureInProgress( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TNoiseHistogram pNoiseHistParams; - TI_STATUS status; - TI_INT32 i; - - /* stop all running measure types */ - for (i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++) - { - if (pMeasurementSRV->bRequestTimerRunning[i]) - { - /* stop timer */ - tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]); - pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; - - /* if necessary, stop measurement type */ - switch ( pMeasurementSRV->msrRequest.msrTypes[ i ].msrType ) - { - case MSR_TYPE_BEACON_MEASUREMENT: - /* send stop AP discovery command */ - status = cmdBld_CmdApDiscoveryStop (pMeasurementSRV->hCmdBld, NULL, NULL); - if ( TI_OK != status ) - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_ApDiscoveryStop returned status %d\n", status); - } - break; - - case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT: - /* Set Noise Histogram Cmd Params */ - pNoiseHistParams.cmd = STOP_NOISE_HIST; - pNoiseHistParams.sampleInterval = 0; - os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[ 0 ]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES ); - - /* Send a Stop command to the FW */ - status = cmdBld_CmdNoiseHistogram (pMeasurementSRV->hCmdBld, &pNoiseHistParams, NULL, NULL); - - if ( TI_OK != status ) - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_NoiseHistogramCmd returned status %d\n", status); - } - break; - - /* These are just to avoid compilation warnings, nothing is actualy done here! */ - case MSR_TYPE_BASIC_MEASUREMENT: - case MSR_TYPE_CCA_LOAD_MEASUREMENT: - case MSR_TYPE_FRAME_MEASUREMENT: - case MSR_TYPE_MAX_NUM_OF_MEASURE_TYPES: - default: - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": unsupported measurement type: %d\n", pMeasurementSRV->msrRequest.msrTypes[ i ].msrType); - break; - } - - /* mark that measurement has failed */ - pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK; - } - } - - /* Send Measurement Stop command to the FW */ - status = cmdBld_CmdMeasurementStop (pMeasurementSRV->hCmdBld, - (void *)pMeasurementSRV->commandResponseCBFunc, - pMeasurementSRV->commandResponseCBObj); - - pMeasurementSRV->commandResponseCBFunc = NULL; - pMeasurementSRV->commandResponseCBObj = NULL; - - if ( TI_OK != status ) - { - TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Failed to send measurement stop command, statud=%d,\n", status); - - /* send a measurement complete event - since it can't be stopped */ - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_STOP_COMPLETE ); - return TI_OK; - } - - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure stop command sent.\n"); - - /* start the FW guard timer */ - pMeasurementSRV->bStartStopTimerRunning = TI_TRUE; - tmr_StartTimer (pMeasurementSRV->hStartStopTimer, - MacServices_measurementSRV_startStopTimerExpired, - (TI_HANDLE)pMeasurementSRV, - MSR_FW_GUARD_TIME, - TI_FALSE); - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief handle a DRIVER_MODE_FAILURE event by calling the response and complete CBs.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_DriverModeFailure( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - - /* this function can be called from within a request (when the power save SRV returned an immediate error), - or in a different context, when power save entry failed. The latter is a valid status, whereas the former - indicates a severe error. However, as there is nothing to do with the former (other than debug it), the same - failure indication is used for both of them, which will make the upper layer (Palau driver or TI measurement - manager) to return to idle state. Still, for the former the error is returned as the return status from the - measurement start API call whereas for the latter the error is indicated both by the command response and - measurement complete CBs status */ - - /* if we are running within a request context, don't call the CBs! The startMeasurement function - will return an invalid status instead */ - if ( TI_FALSE == pMeasurementSRV->bInRequest ) - { - /* if a response CB is available (GWSI) call it */ - if ( NULL != pMeasurementSRV->commandResponseCBFunc ) - { - pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_NOK ); - } - - /* if a complete CB is available (both GWSI and TI driver), call it */ - if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc ) - { - /* mark that all types has failed */ - TI_INT32 i; - for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) - { - pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK; - } - /* call the complete CB */ - pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, - &(pMeasurementSRV->msrReply)); - } - else - { - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": driver mode failure and complete CB is NULL!!!\n"); - } - } - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief handle a START_FAILURE event by exiting driver mode and calling the complete CB.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_measureStartFailure( TI_HANDLE hMeasurementSRV ) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - - /* This function can be called from within a request context (if the driver mode entry process - was immediate), or from the driver mode CB context. Regardless of teh context in which it runs, - The error indicates that something is wrong in the HAL. There is no way to solve this (other than debug it). - The error is either indicating by the measurement start API return status (if still in the request context), - or by calling the response (if available, only in GWSI) and complete CBs with invalid status */ - - /* Switch Power save SRV back to user mode */ - powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL ); - - /* if we are running within a request context, don't call the CB! The startMeasurement function - will return an invalid status instead */ - if ( TI_FALSE == pMeasurementSRV->bInRequest ) - { - /* if a response CB is available (GWSI) call it */ - if ( NULL != pMeasurementSRV->commandResponseCBFunc ) - { - pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_NOK ); - } - - /* if a complete CB is available (both GWSI and TI driver), call it */ - if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc ) - { - /* mark that all types has failed */ - TI_INT32 i; - for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) - { - pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK; - } - /* call the complete CB */ - pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, - &(pMeasurementSRV->msrReply)); - } - else - { - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Start measurement failure and response and complete CBs are NULL!!!\n"); - } - } - - return TI_OK; -} - - -static void measurementSRVSM_requestMeasureStartResponseCB(TI_HANDLE hMeasurementSRV, TI_UINT32 uMboxStatus) -{ - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - -TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": FW has responded with CMD_STATUS = %d\n", uMboxStatus); - - if (uMboxStatus == TI_OK) - { -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": FW has responded with CMD_STATUS_SUCCESS!\n"); - - if ( NULL != pMeasurementSRV->commandResponseCBFunc ) - { - pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_OK ); - } - } - else - { - if (uMboxStatus == SG_REJECT_MEAS_SG_ACTIVE) - { -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": FW has responded with CMD_STATUS_REJECT_MEAS_SG_ACTIVE!\n"); - } - -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": FW has responded with CMD_STATUS NOK!!!\n"); - - - /* if a timer is running, stop it */ - if ( TI_TRUE == pMeasurementSRV->bStartStopTimerRunning ) - { -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "***** STOP TIMER 8 *****\n"); - tmr_StopTimer( pMeasurementSRV->hStartStopTimer ); - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - } - for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) - { - if ( TI_TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] ) - { - tmr_StopTimer( pMeasurementSRV->hRequestTimer[ i ] ); - pMeasurementSRV->bRequestTimerRunning[ i ] = TI_FALSE; - } - } - - measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), - MSR_SRV_EVENT_START_FAILURE ); - } -} - - -/** - * \author Ronen Kalish\n - * \date 23-December-2005\n - * \brief Handles a stop request when no stop is needed (SM is either idle or already send stop command to FW.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSrv - handle to the measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSRVSM_dummyStop( TI_HANDLE hMeasurementSrv ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSrv; - - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_WARNING, ": sending unnecessary stop measurement command to FW...\n"); - - /* send a stop command to FW, to obtain a different context in ehich to cal the command response CB */ - cmdBld_CmdMeasurementStop (pMeasurementSRV->hCmdBld, - (void *)pMeasurementSRV->commandResponseCBFunc, - pMeasurementSRV->commandResponseCBObj); - - pMeasurementSRV->commandResponseCBFunc = NULL; - pMeasurementSRV->commandResponseCBObj = NULL; - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 17-November-2005\n - * \brief Handles an unexpected event.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSrv - handle to the measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS actionUnexpected( TI_HANDLE hMeasurementSrv ) -{ - measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSrv; - TI_INT32 i; - - TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_SM, ": measurement SRV state machine error, unexpected Event\n"); - - if (pMeasurementSRV->bStartStopTimerRunning) - { - tmr_StopTimer (pMeasurementSRV->hStartStopTimer); - pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; - } - - for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) - { - if (pMeasurementSRV->bRequestTimerRunning[i]) - { - tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]); - pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; - } - } - - /* we must clean the old command response CB since they are no longer relevant - since the state machine may be corrupted */ - pMeasurementSRV->commandResponseCBFunc = NULL; - pMeasurementSRV->commandResponseCBObj = NULL; - - /* indicate the unexpected event in the return status */ - pMeasurementSRV->returnStatus = TI_NOK; - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Handles an event that doesn't require any action.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSrv - handle to the measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS actionNop( TI_HANDLE hMeasurementSrv ) -{ - return TI_OK; -} - diff --git a/wl1271/TWD/MacServices/MeasurementSrvSM.h b/wl1271/TWD/MacServices/MeasurementSrvSM.h deleted file mode 100644 index 6c502e98..00000000 --- a/wl1271/TWD/MacServices/MeasurementSrvSM.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * MeasurementSrvSM.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file MeasurementSrv.h - * \brief This file include private definitions for the Measurement SRV state machine. - * \author Ronen Kalish - * \date 08-November-2005 - */ - -#ifndef __MEASUREMENT_SRV_SM_H__ -#define __MEASUREMENT_SRV_SM_H__ - - -/* - *********************************************************************** - * Constant definitions. - *********************************************************************** - */ - - -/* - *********************************************************************** - * Enums. - *********************************************************************** - */ - -/** \enum measurement_SRVSMEvents_e - * \brief enumerates the different measurement SRV state machine events. - */ -typedef enum -{ - MSR_SRV_EVENT_MEASURE_START_REQUEST = 0, - MSR_SRV_EVENT_DRIVER_MODE_SUCCESS, - MSR_SRV_EVENT_DRIVER_MODE_FAILURE, - MSR_SRV_EVENT_START_SUCCESS, - MSR_SRV_EVENT_START_FAILURE, - MSR_SRV_EVENT_ALL_TYPES_COMPLETE, - MSR_SRV_EVENT_STOP_COMPLETE, - MSR_SRV_EVENT_MEASURE_STOP_REQUEST, - MSR_SRV_NUM_OF_EVENTS -} measurement_SRVSMEvents_e; - -/** \enum measurement_SRVSMStates_e - * \brief enumerates the different measurement SRV state machine states. - */ -typedef enum -{ - MSR_SRV_STATE_IDLE =0, - MSR_SRV_STATE_WAIT_FOR_DRIVER_MODE, - MSR_SRV_STATE_WAIT_FOR_MEASURE_START, - MSR_SRV_STATE_MEASURE_IN_PROGRESS, - MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, - MSR_SRV_NUM_OF_STATES -} measurements_SRVSMStates_e; - - -/* - *********************************************************************** - * Typedefs. - *********************************************************************** - */ - - -/* - *********************************************************************** - * Structure definitions. - *********************************************************************** -*/ - -/* - *********************************************************************** - * External data definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External functions definitions - *********************************************************************** - */ - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Initialize the measurement SRV SM.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS measurementSRVSM_init( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Processes an event.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the measurement SRV object.\n - * \param currentState - the current scan SRV SM state.\n - * \param event - the event to handle.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS measurementSRVSM_SMEvent( TI_HANDLE hMeasurementSrv, measurements_SRVSMStates_e* currentState, - measurement_SRVSMEvents_e event ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a MEASURE_START_REQUEST event by requesting driver mode.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_requestDriverMode( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a DRIVER_MODE_SUCCESS event by sending start measure command to the FW.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_requestMeasureStart( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a START_SUCCESS event by starting different measure types and setting timers.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_startMeasureTypes( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle an ALL_TYPE_COMPLETE event by sending a stop measure command to the FW.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_requestMeasureStop( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a STOP_COMPLETE event by exiting driver mode and calling the complete CB.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_completeMeasure( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief Handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE state by exiting driver mode. - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_stopFromWaitForDriverMode( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 27-November-2005\n - * \brief handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE by marking negative result status - * \brief and callin the ordinary stop function - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_stopFromWaitForMeasureStart( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief handle a STOP_REQUEST event when in MEASURE_IN_PROGRESS by stopping all measure types and - * \brief requesting measure stop from the FW.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_stopFromMeasureInProgress( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief handle a DRIVER_MODE_FAILURE event by calling the response CB.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_DriverModeFailure( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 08-November-2005\n - * \brief handle a START_FAILURE event by exiting driver mode and calling the complete CB.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSrv - handle to the Measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSM_measureStartFailure( TI_HANDLE hMeasurementSRV ); - -/** - * \author Ronen Kalish\n - * \date 23-December-2005\n - * \brief Handles a stop request when no stop is needed (SM is either idle or already send stop command to FW.\n - * - * Function Scope \e Private.\n - * \param hMeasurementSrv - handle to the measurement SRV object.\n - * \return always TI_OK.\n - */ -TI_STATUS measurementSRVSRVSM_dummyStop( TI_HANDLE hmeasurementSrv ); - -#endif /* __MEASUREMENT_SRV_SM_H__ */ - diff --git a/wl1271/TWD/MacServices/PowerSrv.c b/wl1271/TWD/MacServices/PowerSrv.c deleted file mode 100644 index 71c33ac6..00000000 --- a/wl1271/TWD/MacServices/PowerSrv.c +++ /dev/null @@ -1,812 +0,0 @@ -/* - * PowerSrv.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file powerSrv.c - * \brief This is the powerSrv module implementation. - * \author Assaf Azulay - * \date 19-Oct-2005 - */ - -/**************************************************************************** - * * - * MODULE: powerSrv * - * PURPOSE: powerSrv Module implementation. * - * * - ****************************************************************************/ - -#define __FILE_ID__ FILE_ID_113 -#include "tidef.h" -#include "osApi.h" -#include "report.h" -#include "timer.h" -#include "PowerSrv.h" -#include "PowerSrv_API.h" -#include "PowerSrvSM.h" -#include "eventMbox_api.h" - - -/***************************************************************************** - ** Defines ** - *****************************************************************************/ - - - -/**************************************************************************************** -** Private Function prototypes ** -****************************************************************************************/ -static void powerSrv802_11PsReport (TI_HANDLE hPowerSrv, char* str , TI_UINT32 strLen); -TI_STATUS powerSrvProcessRequest (TI_HANDLE hPowerSrv, powerSrvMode_e requestMode); -void powerSrvCreatePssRequest (TI_HANDLE hPowerSrv, - powerSrvMode_e requestMode, - powerSrvRequestState_e requestState, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - powerSaveCmpltCB_t powerSaveCompleteCB, - powerSaveCmdResponseCB_t powerSaveCmdResponseCB); - -/*************************************************************************************** -** Functions ** -****************************************************************************************/ - - - -/**************************************************************************************** - * powerSrv_create * - **************************************************************************************** -DESCRIPTION: Power Server module creation function, called by the MAC Services create in creation phase - performs the following: - - Allocate the Power Server handle - - Creates the Power Server State Machine - -INPUT: - hOs - Handle to OS - - -OUTPUT: - -RETURN: Handle to the Power Server module on success, NULL otherwise -****************************************************************************************/ -TI_HANDLE powerSrv_create(TI_HANDLE hOs) -{ - powerSrv_t * pPowerSrv = NULL; - pPowerSrv = (powerSrv_t*) os_memoryAlloc (hOs, sizeof(powerSrv_t)); - if ( pPowerSrv == NULL ) - { - WLAN_OS_REPORT(("powerSrv_create - Memory Allocation Error!\n")); - return NULL; - } - - os_memoryZero (hOs, pPowerSrv, sizeof(powerSrv_t)); - - pPowerSrv->hOS = hOs; - - /*creation of the State Machine*/ - pPowerSrv->hPowerSrvSM = powerSrvSM_create(hOs); - if ( pPowerSrv->hPowerSrvSM == NULL ) - { - WLAN_OS_REPORT(("powerSrv_create - Error in create PowerSrvSM module!\n")); - powerSrv_destroy(pPowerSrv); - return NULL; - } - - return pPowerSrv; - -} - - -/**************************************************************************************** - * powerSrv_destroy * - **************************************************************************************** -DESCRIPTION: Power Server module destroy function, c - - delete Power Server allocation - - call the destroy function of the State machine - -INPUT: - hPowerSrv - Handle to the Power Server - - -OUTPUT: - -RETURN: TI_STATUS - TI_OK on success else TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrv_destroy(TI_HANDLE hPowerSrv) -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - - if ( pPowerSrv->hPowerSrvSM != NULL ) - { - powerSrvSM_destroy(pPowerSrv->hPowerSrvSM); - } - - os_memoryFree(pPowerSrv->hOS , pPowerSrv , sizeof(powerSrv_t)); - - return TI_OK; -} - - -/**************************************************************************************** - * powerSrvSM_init * - **************************************************************************************** -DESCRIPTION: Power Server module initialize function, called by the MAC Services in initialization phase - performs the following: - - init the Power server to active state. - - call the init function of the state machine. - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - hReport - handle to the Report object. - - hEventMbox - handle to the Event Mbox object. - - hCmdBld - handle to the Command Builder object. - -OUTPUT: -RETURN: TI_STATUS - TI_OK on success else TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrv_init (TI_HANDLE hPowerSrv, - TI_HANDLE hReport, - TI_HANDLE hEventMbox, - TI_HANDLE hCmdBld, - TI_HANDLE hTimer) -{ - powerSrv_t* pPowerSrv = (powerSrv_t*)hPowerSrv; - - pPowerSrv->hReport = hReport; - pPowerSrv->hEventMbox = hEventMbox; - - /* - init PowerSrv state machine. - */ - powerSrvSM_init (pPowerSrv->hPowerSrvSM, hReport, hCmdBld, hTimer); - - pPowerSrv->currentMode = USER_MODE; - - /*init all request with init values*/ - powerSrvCreatePssRequest(hPowerSrv, - USER_MODE, - HANDLED_REQUEST, - POWER_SAVE_OFF, - TI_FALSE, - NULL, - NULL, - NULL); - powerSrvCreatePssRequest(hPowerSrv, - DRIVER_MODE, - HANDLED_REQUEST, - POWER_SAVE_OFF, - TI_FALSE, - NULL, - NULL, - NULL); - pPowerSrv->userLastRequestMode = (powerSrvMode_e)POWER_SAVE_OFF; - pPowerSrv->pCurrentRequest = & pPowerSrv->userRequest; - - /* - register for Event - */ - - eventMbox_RegisterEvent (hEventMbox, - TWD_OWN_EVENT_PS_REPORT, - (void *)powerSrv802_11PsReport, - hPowerSrv); - - eventMbox_UnMaskEvent (hEventMbox, TWD_OWN_EVENT_PS_REPORT, NULL, NULL); - - TRACE0(pPowerSrv->hReport, REPORT_SEVERITY_INIT, "powerSrv Initialized \n"); - - return TI_OK; -} - -/**************************************************************************************** - * powerSrv_restart * - **************************************************************************************** -DESCRIPTION: Restart the scan SRV module upon recovery. - - init the Power server to active state. - - call the init function of the state machine. - -INPUT: - hPowerSrv - handle to the PowerSrv object. - -OUTPUT: -RETURN: TI_STATUS - TI_OK on success else TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrv_restart( TI_HANDLE hPowerSrv) -{ - powerSrv_t* pPowerSrv = (powerSrv_t*)hPowerSrv; - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)pPowerSrv->hPowerSrvSM; - /* - init PowerSrv state machine. - */ - /* - the PowerSrvSM start in active mode (POWER_SRV_STATE_ACTIVE) - the PowerSrvSM::currentState must be sync with the PowerSrv::desiredPowerModeProfile (POWER_MODE_ACTIVE). - */ - pPowerSrvSM->currentState = POWER_SRV_STATE_ACTIVE; - pPowerSrv->currentMode = USER_MODE; - tmr_StopTimer (pPowerSrvSM->hPwrSrvSmTimer); - - /*init all request with init values*/ - powerSrvCreatePssRequest(hPowerSrv, - USER_MODE, - HANDLED_REQUEST, - POWER_SAVE_OFF, - TI_FALSE, - NULL, - NULL, - NULL); - powerSrvCreatePssRequest(hPowerSrv, - DRIVER_MODE, - HANDLED_REQUEST, - POWER_SAVE_OFF, - TI_FALSE, - NULL, - NULL, - NULL); - pPowerSrv->userLastRequestMode = (powerSrvMode_e)POWER_SAVE_OFF; - pPowerSrv->pCurrentRequest = & pPowerSrv->userRequest; - - /* - register for Event - */ - eventMbox_RegisterEvent (pPowerSrv->hEventMbox, - TWD_OWN_EVENT_PS_REPORT, - (void *)powerSrv802_11PsReport, - hPowerSrv); - - eventMbox_UnMaskEvent (pPowerSrv->hEventMbox, TWD_OWN_EVENT_PS_REPORT, NULL, NULL); - - return TI_OK; -} - -/**************************************************************************************** - * powerSrv_config * - **************************************************************************************** -DESCRIPTION: Power Server module configuration function, called by the MAC Services in configure phase - performs the following: - - init the Power server to active state. - - call the init function of the state machine. - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - pPowerSrvInitParams - the Power Server initialize parameters. - -OUTPUT: -RETURN: TI_STATUS - TI_OK on success else TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrv_config( TI_HANDLE hPowerSrv, - TPowerSrvInitParams *pPowerSrvInitParams) -{ - powerSrv_t* pPowerSrv = (powerSrv_t*)hPowerSrv; - - /* - config PowerSrv state machine. - */ - powerSrvSM_config( pPowerSrv->hPowerSrvSM, - pPowerSrvInitParams); - - return TI_OK; -} -/**************************************************************************************** - * powerSrv_SetPsMode * - **************************************************************************************** -DESCRIPTION: This function is a user mode request from the Power Save Server. - it will create a Request from the "USER_REQUEST" and will try to perform the user request for PS/Active. - this will be done in respect of priority to Driver request. - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - psMode - Power save/Active request - - sendNullDataOnExit - - - powerSaveCBObject - handle to the Callback function module. - - powerSaveCompleteCB - Callback function - for success/faild notification. -OUTPUT: -RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrv_SetPsMode( TI_HANDLE hPowerSrv, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - powerSaveCmpltCB_t powerSaveCompleteCB, - powerSaveCmdResponseCB_t powerSavecmdResponseCB) - -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - TI_STATUS status; -/*creating the request from type - "user"*/ - powerSrvCreatePssRequest(hPowerSrv, - USER_MODE, - NEW_REQUEST, - psMode, - sendNullDataOnExit, - powerSaveCBObject, - powerSaveCompleteCB, - powerSavecmdResponseCB); - -/*the request will be handled if the Power server is not in Driver mode.*/ - if ( pPowerSrv->currentMode==USER_MODE ) - { - status = powerSrvProcessRequest(hPowerSrv,pPowerSrv->userRequest.requestMode); - } - else/*driver mode*/ - { - pPowerSrv->userRequest.requestState = PENDING_REQUEST; - status = POWER_SAVE_802_11_PENDING; - } - return status; - -} - - -/**************************************************************************************** - * powerSrv_ReservePS * - **************************************************************************************** -DESCRIPTION: This function is a driver mode request to set the 802.11 Power Save state and reserve the module. - The module should not be in driver mode when this request is made. - If this function is called when the module is already in driver mode the result is unexpected. - If the request cannot be fulfilled because of currently executing user mode request, - then the function will return PENDING and the powerSaveCompleteCB function will be called when the request is fulfilled. - If the request can be fulfilled immediately and the Power Save state required is the current state - (This is always the case when PSMode = KEEP_CURRENT), - then the module will be reserved and the function will return TI_OK - the callback function will not be called.?? - If the request can be fulfilled immediately and requires a Power Save state transition, - then the return value will be TI_OK and the powerSaveCompleteCB function will be called by the Power Save Server - when the request is complete. - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - psMode - Power save/Active request - - sendNullDataOnExit - - - powerSaveCBObject - handle to the Callback function module. - - powerSaveCompleteCB - Callback function - for success/faild notification. -OUTPUT: -RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrv_ReservePS( TI_HANDLE hPowerSrv, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - powerSaveCmpltCB_t powerSaveCompleteCB) -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - TI_STATUS status; - - /*creating the request from type - "driver"*/ - if ( psMode == POWER_SAVE_KEEP_CURRENT ) - { - psMode = pPowerSrv->userRequest.psMode; - } - - powerSrvCreatePssRequest(hPowerSrv, - DRIVER_MODE, - NEW_REQUEST, - psMode, - sendNullDataOnExit, - powerSaveCBObject, - powerSaveCompleteCB, - NULL); - /*try to execute the request*/ - status = powerSrvProcessRequest(hPowerSrv,pPowerSrv->driverRequest.requestMode); - return status; - -} - - -/**************************************************************************************** - * powerSrv_ReleasePS * - **************************************************************************************** -DESCRIPTION: This function is used to release a previous driver mode request issued with the ReservPS API. - it creates a Driver request and the server act like it is a normal driver request. - the server will send the request with a simple optimization - if there is a pending or - new user request - the request will be added in the driver request, in this way when the - user request will be executed there will be nothing to do, in the same manner if there - are no user / driver request to execute we will send the last user request in Driver mode. - - - - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - sendNullDataOnExit - - - powerSaveCBObject - handle to the Callback function module. - - powerSaveCompleteCB - Callback function - for success/faild notification. -OUTPUT: -RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrv_ReleasePS( TI_HANDLE hPowerSrv, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - powerSaveCmpltCB_t powerSaveCompleteCB) -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - TI_STATUS status; - - /*creating the request from type - "driver"*/ - - if (pPowerSrv->driverRequest.requestMode == POWER_SAVE_802_11_PENDING) - { - powerSrvCreatePssRequest(hPowerSrv, - DRIVER_MODE, - HANDLED_REQUEST, - POWER_SAVE_OFF, - TI_FALSE, - NULL, - NULL, - NULL); - return POWER_SAVE_802_11_IS_CURRENT; - } - - /*creating the request from type - "driver"*/ - powerSrvCreatePssRequest(hPowerSrv, - DRIVER_MODE, - NEW_REQUEST, - POWER_SAVE_KEEP_CURRENT, - sendNullDataOnExit, - powerSaveCBObject, - powerSaveCompleteCB, - NULL); - if ( pPowerSrv->userRequest.requestState == NEW_REQUEST || - pPowerSrv->userRequest.requestState == PENDING_REQUEST ) - { - pPowerSrv->driverRequest.psMode = pPowerSrv->userRequest.psMode; - } - else - { - pPowerSrv->driverRequest.psMode = (E80211PsMode)pPowerSrv->userLastRequestMode; - } - - - - status = powerSrvProcessRequest(hPowerSrv,pPowerSrv->driverRequest.requestMode); - /*if the request was not executed we should not change the mode*/ - if (status != POWER_SAVE_802_11_PENDING) - { - pPowerSrv->currentMode = USER_MODE; - } - return status; -} - - - -/**************************************************************************************** - * powerSrv_getPsStatus * - ***************************************************************************************** -DESCRIPTION: This function returns the true state of power. - -INPUT: - hPowerSrv - handle to the PowerSrv object. - -OUTPUT: -RETURN: TI_BOOL - true if the SM is in PS state - false otherwise -****************************************************************************************/ -TI_BOOL powerSrv_getPsStatus(TI_HANDLE hPowerSrv) -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - PowerSrvSMStates_e smState; - smState = powerSrvSM_getCurrentState(pPowerSrv->hPowerSrvSM); - return(smState == POWER_SRV_STATE_PS ); -} - - -/**************************************************************************************** -* powerSrv_SetRateModulation * -***************************************************************************************** -DESCRIPTION: Sets the rate modulation according to the current Radio Mode. - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - dot11mode_e - The current radio mode (A or G) - -OUTPUT: -RETURN: TI_BOOL - true if the SM is in PS state - false otherwise -****************************************************************************************/ -void powerSrv_SetRateModulation(TI_HANDLE hPowerSrv, TI_UINT16 rate) -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - powerSrvSM_setRateModulation(pPowerSrv->hPowerSrvSM,rate); - - return; -} - -/** - * \Gets the rate modulation. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrvSM object.\n - * 2) dot11mode_e - The current radio mode (A or G) - * Return: None.\n - */ -TI_UINT32 powerSrv_GetRateModulation(TI_HANDLE hPowerSrv) -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - return powerSrvSM_getRateModulation(pPowerSrv->hPowerSrvSM); -} - - - - -/***************************************************************************** - ** Private Function prototypes ** - *****************************************************************************/ - - -/**************************************************************************************** - * powerSrv802_11PsReport * - **************************************************************************************** -DESCRIPTION: This function is the call back for the TWD control when a PS event triggered - This function is responsible for the process "keep alive". - the function handles the event and sends it to the state machine, after sending the events - the function handles the next request with respect to driver request priority. - if a request is already done then we will call the request call back (if exist!). - - - - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - str - Event string - - strLen - string length - -OUTPUT: -RETURN: void. -****************************************************************************************/ -static void powerSrv802_11PsReport(TI_HANDLE hPowerSrv, char* str , TI_UINT32 strLen) -{ - powerSrv_t * pPowerSrv = (powerSrv_t*)hPowerSrv; - TI_UINT8 PowerSaveStatus; - E80211PsMode currentPsMode; - TI_STATUS status = TI_OK; - - /*copy the event*/ - os_memoryCopy(pPowerSrv->hOS, (void *)&PowerSaveStatus, (void *)str, strLen); - - TRACE1( pPowerSrv->hReport, REPORT_SEVERITY_INFORMATION, "PS callback with status: %d\n", PowerSaveStatus); - - /* Handling the event*/ - switch ( (EventsPowerSave_e)PowerSaveStatus ) - { - case ENTER_POWER_SAVE_FAIL: - case EXIT_POWER_SAVE_FAIL: - TRACE0( pPowerSrv->hReport, REPORT_SEVERITY_WARNING, "Power save enter or exit failed!\n"); - powerSrvSM_SMApi(pPowerSrv->hPowerSrvSM,POWER_SRV_EVENT_FAIL); - break; - - case ENTER_POWER_SAVE_SUCCESS: - case EXIT_POWER_SAVE_SUCCESS: - powerSrvSM_SMApi(pPowerSrv->hPowerSrvSM,POWER_SRV_EVENT_SUCCESS); - /*update the last user request if the request was a user request*/ - if ( pPowerSrv->currentMode == USER_MODE ) - { - pPowerSrv->userLastRequestMode= (powerSrvMode_e)pPowerSrv->userRequest.psMode; - } - break; - - default: - TRACE1( pPowerSrv->hReport, REPORT_SEVERITY_ERROR, "Unrecognized status at PS callback %d\n", PowerSaveStatus ); - break; - } - - /*this reflects the true power save state - power save IFF state machine in PS state.*/ - if ( (EventsPowerSave_e)PowerSaveStatus == ENTER_POWER_SAVE_SUCCESS ) - { - currentPsMode = POWER_SAVE_ON; - } - else - { - currentPsMode = POWER_SAVE_OFF; - } - - /*in case of request has been already handled - calling the CB*/ - if ( pPowerSrv->pCurrentRequest->requestState == HANDLED_REQUEST ) - { - if ( pPowerSrv->pCurrentRequest->powerSrvCompleteCB != NULL ) - { - pPowerSrv->pCurrentRequest->powerSrvCompleteCB( pPowerSrv->pCurrentRequest->powerSaveCBObject, - currentPsMode, - (EventsPowerSave_e)PowerSaveStatus); - - } - } - - /*starting again to handle waiting requests */ - /*priority to driver request*/ - if ( pPowerSrv->driverRequest.requestState == NEW_REQUEST || - pPowerSrv->driverRequest.requestState == PENDING_REQUEST ) - { - status = powerSrvProcessRequest(hPowerSrv,pPowerSrv->driverRequest.requestMode); - } - else/*user request*/ - { - if ( pPowerSrv->currentMode==USER_MODE ) - { - if ( pPowerSrv->userRequest.requestState == NEW_REQUEST|| - pPowerSrv->userRequest.requestState == PENDING_REQUEST ) - { - status = powerSrvProcessRequest(hPowerSrv,pPowerSrv->userRequest.requestMode); - } - - } - } - if ( status == POWER_SAVE_802_11_IS_CURRENT )/*in case of already or habdled*/ - { - if ( pPowerSrv->pCurrentRequest->powerSrvCompleteCB != NULL ) - { - pPowerSrv->pCurrentRequest->powerSrvCompleteCB(pPowerSrv->pCurrentRequest->powerSaveCBObject, - pPowerSrv->pCurrentRequest->psMode, - ((pPowerSrv->pCurrentRequest->psMode == POWER_SAVE_ON) ? - ENTER_POWER_SAVE_SUCCESS : - EXIT_POWER_SAVE_SUCCESS)); - } - } - - -} - - -/**************************************************************************************** - * powerSrvProcessRequest * - **************************************************************************************** -DESCRIPTION: This function receive the request before sending it to the state machine, checks if it - possible to be applied and pass it to the state machine. - - - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - requestMode - Driver or User mode - - -OUTPUT: -RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrvProcessRequest (TI_HANDLE hPowerSrv, powerSrvMode_e requestMode) -{ - PowerSrvSMStates_e powerSrvSmState; - powerSrvRequest_t* pPrcessedRequest; - TI_STATUS smApiStatus; - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - - - -/*determine what is the current request*/ - if ( requestMode == DRIVER_MODE ) - { - pPrcessedRequest = &(pPowerSrv->driverRequest); - } - else - { - pPrcessedRequest = &(pPowerSrv->userRequest); - } - -/*in case that the state machine is in a pending state and it is a driver - request we will return Pending and not call the SM. the request will - be processed in the next event - according to the 802_11_Report.*/ - powerSrvSmState = powerSrvSM_getCurrentState(pPowerSrv->hPowerSrvSM); - - if ( (powerSrvSmState == POWER_SRV_STATE_PEND_ACTIVE || - powerSrvSmState == POWER_SRV_STATE_PEND_PS) && - pPowerSrv->pCurrentRequest->requestMode == DRIVER_MODE ) - { - pPrcessedRequest->requestState = PENDING_REQUEST; - return POWER_SAVE_802_11_PENDING; - } - /*Set the correct request to the SM*/ - powerSrvSm_setSmRequest(pPowerSrv->hPowerSrvSM ,pPrcessedRequest); - - /*call the SM with the correct request*/ - - if ( pPrcessedRequest->psMode == POWER_SAVE_ON ) - { - smApiStatus = powerSrvSM_SMApi(pPowerSrv->hPowerSrvSM,POWER_SRV_EVENT_REQUEST_PS); - } - else - { - smApiStatus = powerSrvSM_SMApi(pPowerSrv->hPowerSrvSM,POWER_SRV_EVENT_REQUEST_ACTIVE); - } - - /*if =! pending updating the current request pointer.*/ - if ( pPrcessedRequest->requestState != PENDING_REQUEST ) - { - pPowerSrv->pCurrentRequest = pPrcessedRequest; - pPowerSrv->currentMode = pPowerSrv->pCurrentRequest->requestMode; - } - - - return smApiStatus; -} - - -/**************************************************************************************** - * powerSrvCreatePssRequest * - **************************************************************************************** -DESCRIPTION: This function create a request acording to it's type: - - User - -Driver - - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - requestMode - request type : Driver/User - - psMode - Power save/Active request - - sendNullDataOnExit - - - powerSaveCBObject - handle to the Callback functin module. - - powerSaveCompleteCB - Calback function - for success/faild notification. - -OUTPUT: -RETURN: void. -****************************************************************************************/ -void powerSrvCreatePssRequest (TI_HANDLE hPowerSrv, - powerSrvMode_e requestMode, - powerSrvRequestState_e requestState, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - powerSaveCmpltCB_t powerSaveCompleteCB, - powerSaveCmdResponseCB_t powerSaveCmdResponseCB) -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - if ( requestMode==USER_MODE ) - { - pPowerSrv->userRequest.requestState = requestState; - pPowerSrv->userRequest.requestMode = requestMode; - pPowerSrv->userRequest.psMode = psMode; - pPowerSrv->userRequest.sendNullDataOnExit = sendNullDataOnExit; - pPowerSrv->userRequest.powerSaveCBObject = powerSaveCBObject; - pPowerSrv->userRequest.powerSrvCompleteCB = powerSaveCompleteCB; - pPowerSrv->userRequest.powerSaveCmdResponseCB = powerSaveCmdResponseCB; - } - else /*driver request*/ - { - pPowerSrv->driverRequest.requestState = requestState; - pPowerSrv->driverRequest.requestMode = requestMode; - pPowerSrv->driverRequest.psMode = psMode; - pPowerSrv->driverRequest.sendNullDataOnExit = sendNullDataOnExit; - pPowerSrv->driverRequest.powerSaveCBObject = powerSaveCBObject; - pPowerSrv->driverRequest.powerSrvCompleteCB = powerSaveCompleteCB; - pPowerSrv->driverRequest.powerSaveCmdResponseCB = NULL; - } -} - - - -/**************************************************************************************** - * powerSrvRegisterFailureEventCB * - **************************************************************************************** -DESCRIPTION: Registers a failure event callback for scan error notifications. - - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - failureEventCB - the failure event callback function.\n - - hFailureEventObj - handle to the object passed to the failure event callback function. - -OUTPUT: -RETURN: void. -****************************************************************************************/ -void powerSrvRegisterFailureEventCB( TI_HANDLE hPowerSrv, - void * failureEventCB, TI_HANDLE hFailureEventObj ) -{ - powerSrv_t *pPowerSrv = (powerSrv_t*)hPowerSrv; - - pPowerSrv->failureEventFunc = (TFailureEventCb)failureEventCB; - pPowerSrv->failureEventObj = hFailureEventObj; - - /* register the failure event CB also with the PS SM */ - powerSrvSM_RegisterFailureEventCB( pPowerSrv->hPowerSrvSM, failureEventCB, hFailureEventObj ); -} - diff --git a/wl1271/TWD/MacServices/PowerSrv.h b/wl1271/TWD/MacServices/PowerSrv.h deleted file mode 100644 index b5f19da9..00000000 --- a/wl1271/TWD/MacServices/PowerSrv.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - * PowerSrv.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file powerSrv.h - * \brief This is the Power Manager module private (internal). - * \author Yaron Menashe - * \date 27-Apr-2004 - */ - -/**************************************************************************** - * * - * MODULE: Power Manager * - * PURPOSE: Power Manager Module private * - * * - ****************************************************************************/ - -#ifndef _POWER_SRV_H_ -#define _POWER_SRV_H_ - -#include "TWDriverInternal.h" -#include "PowerSrv_API.h" - -/*#include "PowerSrvSM.h"*/ - -/***************************************************************************** - ** Constants ** - *****************************************************************************/ - - -/***************************************************************************** - ** Enumerations ** - *****************************************************************************/ - - - - - -/*new Power*/ - - -typedef enum -{ - DRIVER_MODE, - USER_MODE -}powerSrvMode_e; - -typedef enum -{ - NEW_REQUEST, - PENDING_REQUEST, - RUNNING_REQUEST, - HANDLED_REQUEST -}powerSrvRequestState_e; - - -/***************************************************************************** - ** Typedefs ** - *****************************************************************************/ - - - - -/***************************************************************************** - ** Structures ** - *****************************************************************************/ - - - -typedef struct -{ - powerSrvRequestState_e requestState; - powerSrvMode_e requestMode; - E80211PsMode psMode; - TI_BOOL sendNullDataOnExit; - void* powerSaveCBObject; - powerSaveCmpltCB_t powerSrvCompleteCB; - powerSaveCmdResponseCB_t powerSaveCmdResponseCB; -} powerSrvRequest_t; - -/** \struct powerSrv_t - * this structure contain the data of the PowerSrv object. - */ - - -typedef struct -{ - TI_HANDLE hPowerSrvSM; /**< - * Hnadle to the Power Server State Machine object. - */ - - TI_HANDLE hOS; /**< - * Handle to the OS object. - */ - - TI_HANDLE hReport; /**< - * Handle to the Report module. - */ - - TI_HANDLE hEventMbox; /**< Handle to the power controller object via the WhalCtrl. - * Need for configure the desired power mode policy in the system. - */ - TI_HANDLE hCmdBld; - - powerSrvMode_e currentMode; /**< - *holds the current mode of the PSS - driver or user... - */ - - powerSrvMode_e userLastRequestMode; - /**< - * - */ - - powerSrvRequest_t userRequest; /**< - *user request struct. - */ - - powerSrvRequest_t driverRequest; /**< - *driver request struct - */ - - powerSrvRequest_t* pCurrentRequest; /**< - *pointer to the current request - user/driver request - */ - - TFailureEventCb failureEventFunc; /**< - * upper layer Failure Event CB. - * called when the scan command has been Timer Expiry - */ - TI_HANDLE failureEventObj; /**< - * object parameter passed to the failureEventFunc - * when it is called - */ - -} powerSrv_t; - - - -/***************************************************************************** - ** External data definitions ** - *****************************************************************************/ - - -/***************************************************************************** - ** External functions definitions ** - *****************************************************************************/ - - - - - -/***************************************************************************** - ** Public Function prototypes ** - *****************************************************************************/ - -/***************************************************************************** - ** Private Function prototypes ** - *****************************************************************************/ - -/***************************************************************************** - ** Private Function prototypes ** - *****************************************************************************/ - -#endif /* _POWER_SRV_H_ */ - diff --git a/wl1271/TWD/MacServices/PowerSrvSM.c b/wl1271/TWD/MacServices/PowerSrvSM.c deleted file mode 100644 index 173a080f..00000000 --- a/wl1271/TWD/MacServices/PowerSrvSM.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * PowerSrvSM.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file PowerSrvSM.c - * \brief This is the PowerSrvSM module implementation. - * \author Assaf Azulay - * \date 19-OCT-2005 - */ - -/**************************************************************************** - * * - * MODULE: PowerSrvSM * - * PURPOSE: PowerSrvSM Module implementation. * - * * - ****************************************************************************/ - -#define __FILE_ID__ FILE_ID_114 -#include "tidef.h" -#include "osApi.h" -#include "timer.h" -#include "fsm.h" -#include "report.h" -#include "TWDriver.h" -#include "PowerSrvSM.h" -#include "CmdBld.h" - - -/***************************************************************************** - ** Defines ** - *****************************************************************************/ - - -/***************************************************************************** - ** structs ** - *****************************************************************************/ - - -/***************************************************************************** - ** Private Function prototypes ** - *****************************************************************************/ - -static TI_STATUS powerSrvSmSMEvent(TI_UINT8* pCurrentState, - TI_UINT8 event, - TI_HANDLE hPowerSrvSM); -static TI_STATUS powerSrvSmDoUpdateRequest(TI_HANDLE hPowerSrvSM); -static TI_STATUS powerSrvSmDoEnterPowerSave(TI_HANDLE hPowerSrvSM); -static TI_STATUS powerSrvSmDoExitPowerSave(TI_HANDLE hPowerSrvSM); -static TI_STATUS powerSrvSmDoPending(TI_HANDLE hPowerSrvSM); -static TI_STATUS powerSrvSmDoAllready(TI_HANDLE hPowerSrvSM); -static TI_STATUS powerSrvSMActionUnexpected(TI_HANDLE hPowerSrvSM); -static TI_STATUS powerSrvSMSendMBXConfiguration(TI_HANDLE hPowerSrvSM, TI_BOOL PS_disableEnable); -static void powerSrvSMTimerExpired (TI_HANDLE hPowerSrvSM, TI_BOOL bTwdInitOccured); - -/*************************************************************************************** - ** Public Function prototypes ** - ****************************************************************************************/ - - -/**************************************************************************************** - * powerSrvSM_create * - **************************************************************************************** -DESCRIPTION: Power Server SM module creation function, called by the Power Server create in creation phase - performs the following: - - Allocate the Power Server SM handle - - Creates the fsm. - -INPUT: - hOs - Handle to OS - - -OUTPUT: - -RETURN: Handle to the Power Server SM module on success, NULL otherwise -****************************************************************************************/ -TI_HANDLE powerSrvSM_create(TI_HANDLE hOsHandle) -{ - PowerSrvSM_t *pPowerSrvSM = NULL; - fsm_stateMachine_t *pFsm = NULL; - TI_STATUS status; - - pPowerSrvSM = (PowerSrvSM_t*) os_memoryAlloc (hOsHandle, sizeof(PowerSrvSM_t)); - if ( pPowerSrvSM == NULL ) - { - WLAN_OS_REPORT(("%s(%d) - Memory Allocation Error!\n",__FUNCTION__,__LINE__)); - return NULL; - } - - os_memoryZero (hOsHandle, pPowerSrvSM, sizeof(PowerSrvSM_t)); - - pPowerSrvSM->hOS = hOsHandle; - - /* create the generic state-machine */ - status = fsm_Create(hOsHandle, - &pFsm, - (TI_UINT8)POWER_SRV_SM_STATE_NUM, - (TI_UINT8)POWER_SRV_SM_EVENT_NUM); - if ( status != TI_OK ) - { - WLAN_OS_REPORT(("%s(%d) - Error in create FSM!\n",__FUNCTION__,__LINE__)); - powerSrvSM_destroy(pPowerSrvSM); - return NULL; - } - - pPowerSrvSM->hFSM = (TI_HANDLE)pFsm; - - return pPowerSrvSM; -} - - -/**************************************************************************************** - * powerSrvSM_destroy * - **************************************************************************************** -DESCRIPTION: Power Server SM module destroy function, - - delete Power Server SM allocation - - -INPUT: - hPowerSrvSM - Handle to the Power Server SM - - -OUTPUT: - -RETURN: TI_STATUS - TI_OK on success else TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrvSM_destroy(TI_HANDLE hPowerSrvSM) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - TI_HANDLE osHandle = pPowerSrvSM->hOS; - - /* free the timer */ - if (pPowerSrvSM->hPwrSrvSmTimer) - { - tmr_DestroyTimer (pPowerSrvSM->hPwrSrvSmTimer); - } - - /* free the generic SM */ - if ( pPowerSrvSM->hFSM != NULL ) - { - fsm_Unload(osHandle, (fsm_stateMachine_t*)pPowerSrvSM->hFSM); - } - - /* free the Power Save SRV object */ - os_memoryFree(osHandle , pPowerSrvSM , sizeof(PowerSrvSM_t)); - - return TI_OK; -} - - -/**************************************************************************************** -* powerSrvSM_init * -**************************************************************************************** -DESCRIPTION: Power Server SM module initialize function, called by the Power Server init in configure phase - performs the following: - - init the Stet machine states. - - set Active as start state. - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - - hReport - handle to the Report object. - - hCmdBld - handle to the Command Builder object. - - hTimer - handle to the Timer module object. - -OUTPUT: -RETURN: TI_STATUS - TI_OK on success else TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrvSM_init (TI_HANDLE hPowerSrvSM, - TI_HANDLE hReport, - TI_HANDLE hCmdBld, - TI_HANDLE hTimer) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - fsm_actionCell_t smMatrix[POWER_SRV_SM_STATE_NUM][POWER_SRV_SM_EVENT_NUM] = - { - /* - next state and transition action for POWER_SRV_STATE_ACTIVE state - */ - { - /* POWER_SRV_EVENT_REQUEST_ACTIVE */ - {POWER_SRV_STATE_ACTIVE , powerSrvSmDoAllready}, - - /* POWER_SRV_EVENT_REQUEST_PS */ - {POWER_SRV_STATE_PEND_PS , powerSrvSmDoEnterPowerSave}, - - /* POWER_SRV_EVENT_SUCCESS */ - {POWER_SRV_STATE_ACTIVE , powerSrvSMActionUnexpected}, - - /* POWER_SRV_EVENT_FAIL */ - {POWER_SRV_STATE_ACTIVE , powerSrvSMActionUnexpected} - - }, - - /* - next state and transition action for POWER_SRV_STATE_PEND_PS state - */ - { - /* POWER_SRV_EVENT_REQUEST_ACTIVE */ - {POWER_SRV_STATE_PEND_PS , powerSrvSmDoPending}, - - /* POWER_SRV_EVENT_REQUEST_PS */ - {POWER_SRV_STATE_PEND_PS , powerSrvSmDoPending}, - - /* POWER_SRV_EVENT_SUCCESS */ - {POWER_SRV_STATE_PS , powerSrvSmDoUpdateRequest}, - - /* POWER_SRV_EVENT_FAIL */ - {POWER_SRV_STATE_ACTIVE , powerSrvSmDoUpdateRequest} - - }, - /* - next state and transition action for POWER_SRV_STATE_PS state - */ - { - /* POWER_SRV_EVENT_REQUEST_ACTIVE */ - {POWER_SRV_STATE_PEND_ACTIVE , powerSrvSmDoExitPowerSave}, - - /* POWER_SRV_EVENT_REQUEST_PS */ - {POWER_SRV_STATE_PS , powerSrvSmDoAllready}, - - /* POWER_SRV_EVENT_SUCCESS */ - {POWER_SRV_STATE_PS , powerSrvSMActionUnexpected}, - - /* POWER_SRV_EVENT_FAIL */ - {POWER_SRV_STATE_PS , powerSrvSMActionUnexpected} - - }, - /* - next state and transition action for POWER_SRV_STATE_PEND_ACTIVE state - */ - { - /* POWER_SRV_EVENT_REQUEST_ACTIVE */ - {POWER_SRV_STATE_PEND_ACTIVE , powerSrvSmDoPending}, - - /* POWER_SRV_EVENT_REQUEST_PS */ - {POWER_SRV_STATE_PEND_ACTIVE , powerSrvSmDoPending}, - - /* POWER_SRV_EVENT_SUCCESS */ - {POWER_SRV_STATE_ACTIVE , powerSrvSmDoUpdateRequest}, - - /* POWER_SRV_EVENT_FAIL */ - {POWER_SRV_STATE_ERROR_ACTIVE , powerSrvSmDoUpdateRequest} - - }, - /* - next state and transition action for POWER_SRV_STATE_ERROR_ACTIVE state - */ - { - /* POWER_SRV_EVENT_REQUEST_ACTIVE */ - {POWER_SRV_STATE_PEND_ACTIVE , powerSrvSmDoExitPowerSave}, - - /* POWER_SRV_EVENT_REQUEST_PS */ - {POWER_SRV_STATE_PEND_PS , powerSrvSmDoEnterPowerSave}, - - /* POWER_SRV_EVENT_SUCCESS */ - {POWER_SRV_STATE_ERROR_ACTIVE , powerSrvSMActionUnexpected}, - - /* POWER_SRV_EVENT_FAIL */ - {POWER_SRV_STATE_ERROR_ACTIVE , powerSrvSMActionUnexpected} - - }, - - }; - - pPowerSrvSM->hReport = hReport; - pPowerSrvSM->hCmdBld = hCmdBld; - pPowerSrvSM->hTimer = hTimer; - - /* create the timer */ - pPowerSrvSM->hPwrSrvSmTimer = tmr_CreateTimer (pPowerSrvSM->hTimer); - if (pPowerSrvSM->hPwrSrvSmTimer == NULL) - { - TRACE0(pPowerSrvSM->hReport, REPORT_SEVERITY_ERROR, "powerSrvSM_init(): Failed to create hPwrSrvSmTimer!\n"); - return TI_NOK; - } - - fsm_Config(pPowerSrvSM->hFSM, - (fsm_Matrix_t)smMatrix, - POWER_SRV_SM_STATE_NUM, - POWER_SRV_SM_EVENT_NUM, - powerSrvSmSMEvent, - pPowerSrvSM->hOS); - - /* - the PowerSrvSM start in active mode (POWER_SRV_STATE_ACTIVE) - the PowerSrvSM::currentState must be sync with the PowerSrv::desiredPowerModeProfile (POWER_MODE_ACTIVE). - */ - pPowerSrvSM->currentState = POWER_SRV_STATE_ACTIVE; - - - /* - Null packet rate : 2,5.5 M - Probe Request : Not PBCC modulation, Long Preamble */ - pPowerSrvSM->NullPktRateModulation= (DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER); - - TRACE0(pPowerSrvSM->hReport, REPORT_SEVERITY_INIT, "PowerSrvSM Initialized\n"); - - return TI_OK; -} - -/**************************************************************************************** -* powerSrvSM_config * -**************************************************************************************** -DESCRIPTION: Power Server SM module configuration function, called by the Power Server init in configure phase - performs the following: - - init the Stet machine states. - - set Active as start state. - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - - pPowerSrvInitParams - the Power Server initialize parameters. - -OUTPUT: -RETURN: TI_STATUS - TI_OK on success else TI_NOK. -****************************************************************************************/ -TI_STATUS powerSrvSM_config(TI_HANDLE hPowerSrvSM, - TPowerSrvInitParams *pPowerSrvInitParams) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - /* - init PowerMgmtConfigration - */ - pPowerSrvSM->hangOverPeriod = pPowerSrvInitParams->hangOverPeriod; - pPowerSrvSM->numNullPktRetries = pPowerSrvInitParams->numNullPktRetries; - - return TI_OK; -} -/**************************************************************************************** - * powerSrvSM_SMApi * - ***************************************************************************************** -DESCRIPTION: This function triggers events from the outside of the module into the state machine. - - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - - theSMEvent - event from TWD. - - -OUTPUT: -RETURN: TI_STATUS TI_OK / PENDING / TI_NOK -****************************************************************************************/ -TI_STATUS powerSrvSM_SMApi(TI_HANDLE hPowerSrvSM, - PowerSrvSMEvents_e theSMEvent) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - TI_STATUS status; - - switch ( theSMEvent ) - { - case POWER_SRV_EVENT_REQUEST_ACTIVE : - case POWER_SRV_EVENT_REQUEST_PS : - case POWER_SRV_EVENT_FAIL : - case POWER_SRV_EVENT_SUCCESS : - - TRACE1(pPowerSrvSM->hReport, REPORT_SEVERITY_INFORMATION, "powerSrvSM_SMApi(%d) called - legal input parameter.\n",theSMEvent); - break; - - default: - TRACE1(pPowerSrvSM->hReport, REPORT_SEVERITY_WARNING, "powerSrvSM_SMApi(%d) called, input parameter is illegal.",theSMEvent); - return TI_NOK; - } - - - status = powerSrvSmSMEvent((TI_UINT8*)&pPowerSrvSM->currentState, - (TI_UINT8)theSMEvent, - hPowerSrvSM); - - return status; -} - - -/**************************************************************************************** - * powerSrvSm_setSmRequest * - ***************************************************************************************** -DESCRIPTION: This function sets the current SM working request. - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - -powerSrvRequest_t* - pointer to the correct request in the Power server. - -OUTPUT: -RETURN: TI_STATUS - TI_OK -****************************************************************************************/ -TI_STATUS powerSrvSm_setSmRequest(TI_HANDLE hPowerSrvSM,powerSrvRequest_t* pSmRequest) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - pPowerSrvSM->pSmRequest = pSmRequest; - return TI_OK; -} - - -/**************************************************************************************** - * powerSrvSM_getCurrentState * - ***************************************************************************************** -DESCRIPTION: This function returns the current state of the SM. - - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - - -OUTPUT: -RETURN: PowerSrvSMStates_e current state -****************************************************************************************/ -PowerSrvSMStates_e powerSrvSM_getCurrentState(TI_HANDLE hPowerSrvSM) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - return pPowerSrvSM->currentState; -} - -/**************************************************************************************** - * powerSrvSM_setRateModulation * - ***************************************************************************************** -DESCRIPTION: This function sets the Rate Modulation - - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - - rateModulation - desired rate - -OUTPUT: -RETURN: void -****************************************************************************************/ - -void powerSrvSM_setRateModulation(TI_HANDLE hPowerSrvSM, TI_UINT16 rateModulation) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - pPowerSrvSM->NullPktRateModulation= rateModulation; -} - -/**************************************************************************************** - * powerSrvSM_getRateModulation * - ***************************************************************************************** -DESCRIPTION: This function sets the Rate Modulation - - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - -OUTPUT: -RETURN: - desired rate -****************************************************************************************/ - -TI_UINT32 powerSrvSM_getRateModulation(TI_HANDLE hPowerSrvSM) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - return pPowerSrvSM->NullPktRateModulation; -} - -/**************************************************************************************** - * powerSrvSM_printObject * - ***************************************************************************************** -DESCRIPTION: This function prints the SM object - - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - - -OUTPUT: -RETURN: void -****************************************************************************************/ -void powerSrvSM_printObject(TI_HANDLE hPowerSrvSM) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - char *pString; - - WLAN_OS_REPORT(("\n+++++ powerSrvSM_printObject +++++\n")); - WLAN_OS_REPORT(("Handle to the CmdBld is 0x%08X\n", pPowerSrvSM->hCmdBld)); - WLAN_OS_REPORT(("Handle to the OS is 0x%08X\n", pPowerSrvSM->hOS)); - WLAN_OS_REPORT(("Handle to the Report is 0x%08X\n", pPowerSrvSM->hReport)); - WLAN_OS_REPORT(("Handle to the FSM is 0x%08X\n", pPowerSrvSM->hFSM)); - - switch ( pPowerSrvSM->currentState ) - { - case POWER_SRV_STATE_ACTIVE: - pString = "POWER_SRV_STATE_ACTIVE"; - break; - - case POWER_SRV_STATE_PEND_PS: - pString = "POWER_SRV_STATE_PEND_PS"; - break; - - case POWER_SRV_STATE_PS: - pString = "POWER_SRV_STATE_PS"; - break; - - case POWER_SRV_STATE_PEND_ACTIVE: - pString = "POWER_SRV_STATE_PEND_ACTIVE"; - break; - - case POWER_SRV_STATE_ERROR_ACTIVE: - pString = "POWER_SRV_STATE_ERROR_ACTIVE"; - break; - - - default: - pString = "UNKWON PARAMETER"; - break; - } - WLAN_OS_REPORT(("The current state of the state machine is %s (=%d)\n", - pString, - pPowerSrvSM->currentState)); - -} - - - - -/***************************************************************************** - ** Private Function prototypes ** - *****************************************************************************/ - - - - - - -/**************************************************************************************** - * powerSrvSmDoEnterPowerSave * - ***************************************************************************************** -DESCRIPTION: This function is an action of the state machine to move from active state to PS - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - -OUTPUT: -RETURN: TI_STATUS - TI_OK / TI_NOK -****************************************************************************************/ - -static TI_STATUS powerSrvSmDoEnterPowerSave(TI_HANDLE hPowerSrvSM) -{ - TI_STATUS status; - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - pPowerSrvSM->pSmRequest->requestState = RUNNING_REQUEST; - status = powerSrvSMSendMBXConfiguration(hPowerSrvSM, TI_TRUE); - return status; -} - - -/**************************************************************************************** - * powerSrvSmDoExitPowerSave * - ***************************************************************************************** -DESCRIPTION: This function is an action of the state machine to move from PS state to Active - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - -OUTPUT: -RETURN: TI_STATUS - TI_OK / TI_NOK -****************************************************************************************/ -static TI_STATUS powerSrvSmDoExitPowerSave(TI_HANDLE hPowerSrvSM) -{ - TI_STATUS status; - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - pPowerSrvSM->pSmRequest->requestState = RUNNING_REQUEST; - status = powerSrvSMSendMBXConfiguration(hPowerSrvSM, TI_FALSE); - return status; -} - - -/**************************************************************************************** - * powerSrvSmDoUpdateRequest * - ***************************************************************************************** -DESCRIPTION: This function is an action of the state machine to update a request when the SM - is already in the requested state is already - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - -OUTPUT: -RETURN: TI_STATUS - TI_OK / TI_NOK -****************************************************************************************/ - -static TI_STATUS powerSrvSmDoUpdateRequest(TI_HANDLE hPowerSrvSM) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - /* request has completed - stop the guard timer */ - tmr_StopTimer (pPowerSrvSM->hPwrSrvSmTimer); - - /*powerSrv_SetRequestState will update the correct request (acording to the current active request)*/ - if ( pPowerSrvSM->pSmRequest->requestState == RUNNING_REQUEST ) - { - pPowerSrvSM->pSmRequest->requestState = HANDLED_REQUEST; - } - - return TI_OK; -} - - -/**************************************************************************************** - * powerSrvSmDoPending * - ***************************************************************************************** -DESCRIPTION: This function is an action of the state machine returns Pending in case that there is a request - waiting to be finished (already sent to FW) - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - -OUTPUT: -RETURN: TI_STATUS - PENDING -****************************************************************************************/ - -static TI_STATUS powerSrvSmDoPending(TI_HANDLE hPowerSrvSM) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - /*powerSrv_SetRequestState will check the mode and will update the correct request (Driver of user)*/ - pPowerSrvSM->pSmRequest->requestState = PENDING_REQUEST; - return POWER_SAVE_802_11_PENDING; -} - - - -/**************************************************************************************** - * powerSrvSmDoAllready * - ***************************************************************************************** -DESCRIPTION: This function is an action of the state machine stays in the same state since it the requested - one in the request - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - -OUTPUT: -RETURN: TI_STATUS - TI_OK -****************************************************************************************/ -static TI_STATUS powerSrvSmDoAllready(TI_HANDLE hPowerSrvSM) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - /*powerSrv_SetRequestState will check the mode and will update the correct request (Driver of user)*/ - pPowerSrvSM->pSmRequest->requestState = HANDLED_REQUEST; - return POWER_SAVE_802_11_IS_CURRENT; -} - - -/**************************************************************************************** - * powerSrvSMActionUnexpected * - ***************************************************************************************** -DESCRIPTION: This function is an action of the state machine stays in the same state and return that action - was not expected - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - -OUTPUT: -RETURN: TI_STATUS - TI_OK -****************************************************************************************/ -static TI_STATUS powerSrvSMActionUnexpected(TI_HANDLE hPowerSrvSM) -{ -#ifdef TI_DBG - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - TRACE0(pPowerSrvSM->hReport, REPORT_SEVERITY_ERROR, "called: powerSrvSMActionUnexpected"); -#endif /* TI_DBG */ - - return TI_OK; -} - - -/**************************************************************************************** - * powerSrvSmSMEvent * - ***************************************************************************************** -DESCRIPTION: This function is the manager of the state macine. its move the state machine - from one state to the other depend on the receive event, and call to the appropriate - action (function) for the move between the states. - -INPUT: - pCurrentState - - event - - hPowerSrvSM - handle to the PowerSrvSM object. - -OUTPUT: -RETURN: TI_STATUS -****************************************************************************************/ -static TI_STATUS powerSrvSmSMEvent(TI_UINT8* pCurrentState, - TI_UINT8 event, - TI_HANDLE hPowerSrvSM) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - TI_STATUS status = TI_OK; - TI_UINT8 nextState; - - status = fsm_GetNextState((fsm_stateMachine_t*)pPowerSrvSM->hFSM, - (TI_UINT8)pPowerSrvSM->currentState, - event, - &nextState); - if ( status != TI_OK ) - { - TRACE0(pPowerSrvSM->hReport, REPORT_SEVERITY_SM, "PowerSrvSM - State machine error, failed getting next state\n"); - return(status); - } - - - TRACE3( pPowerSrvSM->hReport, REPORT_SEVERITY_INFORMATION, "powerSrvSmSMEvent: <currentState = %d, event = %d> --> nextState = %d\n", *pCurrentState, event, nextState); - - status = fsm_Event(pPowerSrvSM->hFSM, - pCurrentState, - event, - (void*)pPowerSrvSM); - - return status; -} - - -/**************************************************************************************** -* powerSrvSMSendMBXConfiguration * -***************************************************************************************** -DESCRIPTION: This function send configuration of the power save option that holds in the command - mailbox inner sturcture. - -INPUT: - hPowerSrvSM - handle to the PowerSrvSM object. - - PS_disableEnable - true = PS , false = active - -OUTPUT: -RETURN: TI_STATUS -****************************************************************************************/ -static TI_STATUS powerSrvSMSendMBXConfiguration(TI_HANDLE hPowerSrvSM, TI_BOOL PS_disableEnable) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - TPowerSaveParams powerSaveParams; - TI_STATUS status; - - /*setting the params for the Hal*/ - powerSaveParams.hangOverPeriod = pPowerSrvSM->hangOverPeriod; - powerSaveParams.numNullPktRetries = pPowerSrvSM->numNullPktRetries; - powerSaveParams.NullPktRateModulation = pPowerSrvSM->NullPktRateModulation; - powerSaveParams.needToSendNullData = pPowerSrvSM->pSmRequest->sendNullDataOnExit; - powerSaveParams.ps802_11Enable = PS_disableEnable; - - /* start the FW guard timer, which is used to protect from FW stuck */ - tmr_StartTimer (pPowerSrvSM->hPwrSrvSmTimer, - powerSrvSMTimerExpired, - (TI_HANDLE)pPowerSrvSM, - POWER_SAVE_GUARD_TIME_MS, - TI_FALSE); - - /* that command should be sent to FW just in case we moved from Active to one of the PS modes - * and vice versa, it shoul not be sent when moving between different PS modes */ - status = cmdBld_CmdSetPsMode (pPowerSrvSM->hCmdBld, - &powerSaveParams, - (void *)pPowerSrvSM->pSmRequest->powerSaveCmdResponseCB, - (pPowerSrvSM->pSmRequest->powerSaveCmdResponseCB == NULL) ? NULL : pPowerSrvSM->pSmRequest->powerSaveCBObject); - - if ( status != TI_OK ) - { - TRACE0(pPowerSrvSM->hReport, REPORT_SEVERITY_ERROR, "Error in configuring Power Manager paramters!\n"); - } - - return status; -} - -/**************************************************************************************** -* powerSrvSMTimerExpired * -***************************************************************************************** -DESCRIPTION: This function is called upon timer expiry - when the FW has not returned - a response within the defined tme (50 ms) - -INPUT: hPowerSrvSM - handle to the PowerSrvSM object. - bTwdInitOccured - Indicates if TWDriver recovery occured since timer started - -OUTPUT: None - -RETURN: None -****************************************************************************************/ -static void powerSrvSMTimerExpired (TI_HANDLE hPowerSrvSM, TI_BOOL bTwdInitOccured) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - /* Print an error message */ - TRACE0(pPowerSrvSM->hReport, REPORT_SEVERITY_ERROR, "PS guard timer expired!\n"); - - /* Call the error notification callback (triggering recovery) */ - pPowerSrvSM->failureEventCB( pPowerSrvSM->hFailureEventObj ,POWER_SAVE_FAILURE ); -} - -/**************************************************************************************** - * powerSrvRegisterFailureEventCB * - **************************************************************************************** -DESCRIPTION: Registers a failure event callback for PS SM error notifications. - - -INPUT: - hPowerSrv - handle to the PowerSrv object. - - failureEventCB - the failure event callback function.\n - - hFailureEventObj - handle to the object passed to the failure event callback function. - -OUTPUT: -RETURN: void. -****************************************************************************************/ -void powerSrvSM_RegisterFailureEventCB( TI_HANDLE hPowerSrvSM, - void *failureEventCB, TI_HANDLE hFailureEventObj ) -{ - PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM; - - pPowerSrvSM->failureEventCB = (TFailureEventCb)failureEventCB; - pPowerSrvSM->hFailureEventObj = hFailureEventObj; -} - diff --git a/wl1271/TWD/MacServices/PowerSrvSM.h b/wl1271/TWD/MacServices/PowerSrvSM.h deleted file mode 100644 index 97464ac8..00000000 --- a/wl1271/TWD/MacServices/PowerSrvSM.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - * PowerSrvSM.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file PowerSrvSM.h - * \brief This is the PowerSrv module API. - * \author Assaf Azulay - * \date 6-Oct-2005 - */ - -/**************************************************************************** - * * - * MODULE: PowerSrv * - * PURPOSE: Power Server State machine API * - * * - ****************************************************************************/ - -#ifndef _POWER_SRV_SM_H_ -#define _POWER_SRV_SM_H_ - -#include "PowerSrv_API.h" -#include "PowerSrv.h" - - - -/***************************************************************************** - ** Constants ** - *****************************************************************************/ - -#define POWER_SAVE_GUARD_TIME_MS 5000 /* The gaurd time used to protect from FW stuck */ - -/***************************************************************************** - ** Enumerations ** - *****************************************************************************/ - -/** \enum PowerSrvSMEvents_e */ -typedef enum -{ - POWER_SRV_EVENT_REQUEST_ACTIVE , - POWER_SRV_EVENT_REQUEST_PS , - POWER_SRV_EVENT_SUCCESS, - POWER_SRV_EVENT_FAIL , - POWER_SRV_SM_EVENT_NUM -}PowerSrvSMEvents_e; - -/** \enum PowerSrvSMStates_e */ -typedef enum -{ - POWER_SRV_STATE_ACTIVE = 0, - POWER_SRV_STATE_PEND_PS , - POWER_SRV_STATE_PS , - POWER_SRV_STATE_PEND_ACTIVE , - POWER_SRV_STATE_ERROR_ACTIVE, - POWER_SRV_SM_STATE_NUM -}PowerSrvSMStates_e; - - - -/***************************************************************************** - ** Structures ** - *****************************************************************************/ - -/** \struct PowerSrvSM_t */ -typedef struct -{ - TI_HANDLE hCmdBld; /**< - * Handle to the power controller object via the command builder. - * Need for configure the desired power mode policy in the system. - */ - - TI_HANDLE hOS; /**< Handle to the OS object. */ - - TI_HANDLE hReport; /**< Handle to the Report module. */ - - TI_HANDLE hFSM; /**< Handle to the State machine module. */ - - TI_HANDLE hTimer; /**< Handle to the Timer module. */ - - TI_HANDLE hPwrSrvSmTimer; /**< Guard timer for PS commands sent to the FW */ - - PowerSrvSMStates_e currentState; /**< the current state of the state machine. */ - - powerSrvRequest_t* pSmRequest; /**< pointer to the relevant request in the power server. */ - - TI_UINT8 hangOverPeriod; /**< parameter for the FW */ - - TI_UINT8 numNullPktRetries; /**< parameter for the FW */ - - EHwRateBitFiled NullPktRateModulation; /**< parameter for the FW */ - - TFailureEventCb failureEventCB; /**< Failure event callback */ - - TI_HANDLE hFailureEventObj; /**< Failure event object (supplied to the above callback) */ -} PowerSrvSM_t; - - - - - - - -/***************************************************************************** - ** External data definitions ** - *****************************************************************************/ - - -/***************************************************************************** - ** External functions definitions ** - *****************************************************************************/ - - -/***************************************************************************** - ** Public Function prototypes ** - *****************************************************************************/ - -/** - * \author Assaf Azulay - * \date 6-Oct-2005\n - * \brief Creates the object of the PowerSrv. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the OS.\n - * Return Value: TI_HANDLE - handle to the PowerSrv object.\n - */ -TI_HANDLE powerSrvSM_create(TI_HANDLE hOsHandle); - -/** - * \author Assaf Azulay - * \date 6-Oct-2005\n - * \brief Destroy the object of the PowerSrvSM. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrv object.\n - * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n - */ -TI_STATUS powerSrvSM_destroy(TI_HANDLE thePowerSrvSMHandle); - -/** - * \author Assaf Azulay - * \date 6-Oct-2005\n - * \brief Initialize the PowerSrvSM module. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrvSM object.\n - * 2) TI_HANDLE - handle to the Report object. - * 3) TI_HANDLE - handle to the Command Builder object. - * 4) TI_HANDLE - handle to the Timer module object. - * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n - */ -TI_STATUS powerSrvSM_init (TI_HANDLE hPowerSrvSM, - TI_HANDLE hReport, - TI_HANDLE hCmdBld, - TI_HANDLE hTimer); - -TI_STATUS powerSrvSM_config(TI_HANDLE hPowerSrvSM, - TPowerSrvInitParams *pPowerSrvInitParams); -/** - * \author Assaf Azulay - * \date 6-Oct-2005\n - * \brief return the component version. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrvSM object.\n - * Return Value: TI_UINT32 - component version code.\n - */ - -TI_STATUS powerSrvSM_SMApi(TI_HANDLE hPowerSrvSM, - PowerSrvSMEvents_e theSMEvent); - - -/** - * \author Assaf Azulay - * \date 020-Oct-2005\n - * \brief This function sets the current SM working request.\n - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrvSM object.\n - * 2) powerSrvRequest_t* pSmRequest - desierd request./n - * Return Value: TI_STATUS - TI_OK.\n - */ -TI_STATUS powerSrvSm_setSmRequest(TI_HANDLE hPowerSrvSM,powerSrvRequest_t* pSmRequest); - - - -/** - * \author Assaf Azulay - * \date 09-Jun-2004\n - * \brief get the current state of the state machine. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrvSM object.\n - * Return Value: PowerCtrlSMStates_e.\n - */ -PowerSrvSMStates_e powerSrvSM_getCurrentState(TI_HANDLE hPowerSrvSM); - - -/** - * \author Assaf Azulay - * \date 20-July-2004\n - * \brief sets rate modulation - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrvSM object.\n - * 2) rate_e rate modulation - * Return Value: void.\n - */ -void powerSrvSM_setRateModulation(TI_HANDLE hPowerSrvSM, TI_UINT16 rateModulation); - -/** - * \brief sets rate modulation - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrvSM object.\n* - * Return Value: TI_UINT16 Rate.\n - */ -TI_UINT32 powerSrvSM_getRateModulation(TI_HANDLE hPowerSrvSM); - -/** - * \author Assaf Azulay - * \date 20-July-2004\n - * \brief print configuration of the PowerSrvSM object - use for debug! - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the PowerSrvSM object.\n - * Return Value: void.\n - */ -void powerSrvSM_printObject(TI_HANDLE hPowerSrvSM); - -/** - * \author Ronen Kalish - * \date 21-August-2006\n - * \brief Registers a failure event callback for power save error notifications (timer expiry).\n - * - * Function Scope \e Public.\n - * Parameters:\n - * - hPowerSrvSM - handle to the PowerSrv object. - * - failureEventCB - the failure event callback function. - * - hFailureEventObj - handle to the object passed to the failure event callback function. -*/ -void powerSrvSM_RegisterFailureEventCB( TI_HANDLE hPowerSrvSM, - void* failureEventCB, TI_HANDLE hFailureEventObj ); -#endif /* _POWER_SRV_SM_H_ */ - diff --git a/wl1271/TWD/MacServices/PowerSrv_API.h b/wl1271/TWD/MacServices/PowerSrv_API.h deleted file mode 100644 index 9aca40e0..00000000 --- a/wl1271/TWD/MacServices/PowerSrv_API.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - * PowerSrv_API.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file powerSrv_API.h - * \brief This is the Power Manager module API. - * \author Yaron Menashe - */ - -/**************************************************************************** - * * - * MODULE: Power Server * - * PURPOSE: Power Server Module API * - * * - ****************************************************************************/ - -#ifndef _POWER_SRV_API_H_ -#define _POWER_SRV_API_H_ - -#include "MacServices_api.h" - -/***************************************************************************** - ** Constants ** - *****************************************************************************/ - - -/***************************************************************************** - ** Enumerations ** - *****************************************************************************/ - - - -/***************************************************************************** - ** Typedefs ** - *****************************************************************************/ -/*typedef void (*powerSaveCmdResponseCB_t )(TI_HANDLE cmdResponseHandle,TI_UINT8 MboxStatus);*/ -typedef TPowerSaveResponseCb powerSaveCmdResponseCB_t; -/*typedef void (*powerSaveCmpltCB_t )(TI_HANDLE powerSaveCmpltHandle,TI_UINT8 PSMode,TI_UINT8 transStatus);*/ -typedef TPowerSaveCompleteCb powerSaveCmpltCB_t; -/***************************************************************************** - ** Structures ** - *****************************************************************************/ - - - - -/***************************************************************************** - ** External data definitions ** - *****************************************************************************/ - - -/***************************************************************************** - ** External functions definitions ** - *****************************************************************************/ - - -/***************************************************************************** - ** Public Function prototypes ** - *****************************************************************************/ - - -/** - * \author Assaf Azulay - * \date 20-Oct-2005\n - * \brief Creates the object of the power Server. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the OS.\n - * Return Value: TI_HANDLE - handle to the powerSrv object.\n - */ -TI_HANDLE powerSrv_create(TI_HANDLE hOs); - - -/** - * \author Assaf Azulay - * \date 27-Apr-2005\n - * \brief Destroy the object of the power Server. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n - */ -TI_STATUS powerSrv_destroy(TI_HANDLE hPowerSrv); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief Initialization of the powerSrv module. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * 3) TI_HANDLE - handle to the Report object.\n - * 2) TI_HANDLE - handle to the EventMbox object.\n - * 4) TI_HANDLE - handle to the CommandBuilder object.\n - * 5) TI_HANDLE - handle to the Timer module object.\n - * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n - */ -TI_STATUS powerSrv_init (TI_HANDLE hPowerSrv, - TI_HANDLE hReport, - TI_HANDLE hEventMbox, - TI_HANDLE hCmdBld, - TI_HANDLE hTimer); - - -TI_STATUS powerSrv_config(TI_HANDLE hPowerSrv, - TPowerSrvInitParams *pPowerSrvInitParams); - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief request PS by User - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) hPowerSrv - handle to the PowerSrv object.\n - * 2) psMode - Power save/Active request.\n - * 3) sendNullDataOnExit - \n - * 4) powerSaveCompleteCBObject - handle to the Callback functin module.\n - * 5) powerSaveCompleteCB - Calback function - for success/faild notification.\n - * 6) powerSavecmdResponseCB - Calback function - for GWSI success/faild notification.\n - * Return Value: TI_STATUS - TI_OK / PENDING / TI_NOK.\n - * \b Description:\n - * This function is a user mode request from the Power Save Server./n - * it will create a Request from typ "USER_REQUEST" and will try to perform the user request for PS/Active./n - * this will be done in respect of priority to Driver request./n - */ -TI_STATUS powerSrv_SetPsMode (TI_HANDLE hPowerSrv, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCompleteCBObject, - powerSaveCmpltCB_t powerSaveCompleteCB, - powerSaveCmdResponseCB_t powerSavecmdResponseCB); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief SW configure, use to override the current PowerMode (what ever it will be) to - * active/PS combined with awake/power-down. use for temporary change the system policy. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * 2) powerSrv_RequestFor_802_11_PS_e - the driver mode obliged to be in 802.11 PS or not change.\n - * 3) PowerCtrl_PowerLevel_e - the desired driver power level (allowed: AWAKE or POWER DOWN).\n - * 4) TI_HANDLE theObjectHandle - the handle the object that need the PS success/fail notification.\n - * 5) ps802_11_NotificationCB_t - the callback function.\n - * 6) char* - the clinet name that ask for driver mode.\n - * Return Value: TI_STATUS - if success (already in power save) then TI_OK,\n - * if pend (wait to ACK form AP for the null data frame) then PENDING\n - * if PS isn't enabled then POWER_SAVE_802_11_NOT_ALLOWED\n - * else TI_NOK.\n - * \b Description:\n - * enter in to configuration of the driver that in higher priority from the user.\n - * the configuration is:\n - * - to enter to802.11 PS or not (if not this isn't a request to get out from 802.11 PS).\n - * - to change the HW power level to awake or power-down if not already there. - * this is a must request.\n -*/ -TI_STATUS powerSrv_ReservePS (TI_HANDLE hPowerSrv, - E80211PsMode psMode, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - powerSaveCmpltCB_t powerSaveCompleteCB); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief end the temporary change of system policy, and returns to the user system policy. - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * 2) char* - the clinet name that ask for driver mode.\n - * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n - * \b Description:\n - * enter in to configuration of the driver that in higher priority from the user.\n - * the configuration is:\n - * end the user mode configuration (driver mode priority) and returns the user configuration - * (user mode priority). -*/ -TI_STATUS powerSrv_ReleasePS( TI_HANDLE hPowerSrv, - TI_BOOL sendNullDataOnExit, - void * powerSaveCBObject, - powerSaveCmpltCB_t powerSaveCompleteCB); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \brief reflects the actual state of the state machine - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * Return Value:\n - * TI_BOOL - thre is in PS false otherwise.\n -*/ -TI_BOOL powerSrv_getPsStatus(TI_HANDLE hPowerSrv); - - -/** - * \author Assaf Azulay - * \date 24-Oct-2005\n - * \sets the rate as got from user else sets default value.\n - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * 2) TI_UINT16 - desierd rate .\n - * Return Value:\n - * void.\n -*/ -void powerSrv_SetRateModulation(TI_HANDLE hPowerSrv, TI_UINT16 rate); - - - -/** - * \author Assaf Azulay - * \date 9-Mar-2006\n - * \brief Registers a failure event callback for scan error notifications. - * - * Function Scope \e Public.\n - * Parameters:\n - * - hPowerSrv - handle to the PowerSrv object. - * - failureEventCB - the failure event callback function. - * - hFailureEventObj - handle to the object passed to the failure event callback function. -*/ -void powerSrvRegisterFailureEventCB( TI_HANDLE hPowerSrv, - void * failureEventCB, TI_HANDLE hFailureEventObj ); - - -/** - * \date 03-Jul-2006\n - * \return the rate as it was seted by powerSrv_SetRateModulation.\n - * - * Function Scope \e Public.\n - * Parameters:\n - * 1) TI_HANDLE - handle to the powerSrv object.\n - * Return Value: TI_UINT16 - desierd rate .\n - * void.\n -*/ -TI_UINT32 powerSrv_GetRateModulation(TI_HANDLE hPowerSrv); - -TI_STATUS powerSrv_restart( TI_HANDLE hPowerSrv); - -#endif /* _POWER_SRV_API_H_ */ diff --git a/wl1271/TWD/MacServices/ScanSrv.c b/wl1271/TWD/MacServices/ScanSrv.c deleted file mode 100644 index cdb64643..00000000 --- a/wl1271/TWD/MacServices/ScanSrv.c +++ /dev/null @@ -1,756 +0,0 @@ -/* - * ScanSrv.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file ScanSrv.c - * \brief This file include the scan SRV module implementation - * - * \see ScanSrv.h, ScanSrvSm.h, ScanSrvSm.c - */ - - -#define __FILE_ID__ FILE_ID_115 -#include "report.h" -#include "timer.h" -#include "ScanSrv.h" -#include "ScanSrvSM.h" -#include "MacServices.h" -#include "MacServices_api.h" -#include "eventMbox_api.h" -#include "CmdBld.h" - -/** - * \\n - * \date 16-Oct-2004\n - * \brief Creates the scan SRV object - * - * Function Scope \e Public.\n - * \param hOS - handle to the OS object.\n - * \return a handle to the scan SRV object, NULL if an error occurred.\n - */ -TI_HANDLE MacServices_scanSRV_create( TI_HANDLE hOS ) -{ - /* allocate the scan SRV object */ - scanSRV_t *pScanSRV = os_memoryAlloc( hOS, sizeof(scanSRV_t)); - if ( NULL == pScanSRV ) - { - WLAN_OS_REPORT( ("ERROR: Failed to create scan SRV module")); - return NULL; - } - - os_memoryZero( pScanSRV->hOS, pScanSRV, sizeof(scanSRV_t)); - - /* allocate the state machine */ - if ( TI_OK != fsm_Create( hOS, &(pScanSRV->SM), SCAN_SRV_NUM_OF_STATES, SCAN_SRV_NUM_OF_EVENTS )) - { - WLAN_OS_REPORT( ("ERROR: Failed to allocate scan SRV state machine")); - os_memoryFree( hOS, pScanSRV, sizeof(scanSRV_t)); - return NULL; - } - - /* store the OS handle */ - pScanSRV->hOS = hOS; - - return pScanSRV; -} - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Finalizes the scan SRV module (releasing memory and timer) - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - */ -void MacServices_scanSRV_destroy( TI_HANDLE hScanSRV ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV; - - /* free timer */ - if (pScanSRV->hScanSrvTimer) - { - tmr_DestroyTimer (pScanSRV->hScanSrvTimer); - } - - /* free memory */ - fsm_Unload( pScanSRV->hOS, pScanSRV->SM ); - os_memoryFree( pScanSRV->hOS, (TI_HANDLE)pScanSRV , sizeof(scanSRV_t)); -} - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Initializes the scan SRV module, registers SCAN_COMPLETE to HAL. - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param Handles of other modules.\n - */ -TI_STATUS MacServices_scanSRV_init (TI_HANDLE hMacServices, - TI_HANDLE hReport, - TI_HANDLE hTWD, - TI_HANDLE hTimer, - TI_HANDLE hEventMbox, - TI_HANDLE hCmdBld) -{ - MacServices_t* pMacServices = (MacServices_t*)hMacServices; - scanSRV_t *pScanSRV = pMacServices->hScanSRV; - - /* store handles */ - pScanSRV->hTWD = hTWD; - pScanSRV->hTimer = hTimer; - pScanSRV->hReport = hReport; - pScanSRV->hEventMbox = hEventMbox; - pScanSRV->hPowerSrv = pMacServices->hPowerSrv; - pScanSRV->hCmdBld = hCmdBld; - pScanSRV->commandResponseFunc = NULL; - pScanSRV->commandResponseObj = NULL; - - /* create the timer */ - pScanSRV->hScanSrvTimer = tmr_CreateTimer (pScanSRV->hTimer); - if (pScanSRV->hScanSrvTimer == NULL) - { - TRACE0(pScanSRV->hReport, REPORT_SEVERITY_ERROR, "MacServices_scanSRV_init(): Failed to create hScanSrvTimer!\n"); - return TI_NOK; - } - - /* init state machine */ - scanSRVSM_init ((TI_HANDLE)pScanSRV); - - /* Register our scan complete handler to the HAL events mailbox */ - eventMbox_RegisterEvent (pScanSRV->hEventMbox, - TWD_OWN_EVENT_SCAN_CMPLT, - (void *)MacServices_scanSRV_scanCompleteCB, - (TI_HANDLE)pScanSRV); - eventMbox_RegisterEvent (pScanSRV->hEventMbox, - TWD_OWN_EVENT_SPS_SCAN_CMPLT, - (void *)MacServices_scanSRV_scanCompleteCB, - (TI_HANDLE)pScanSRV); - - /* init other stuff */ - pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents = 0; - - TRACE0( hReport, REPORT_SEVERITY_INIT, ".....Scan SRV configured successfully.\n"); - - return TI_OK; -} - -/** - * \brief Restart the scan SRV module upon recovery. - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - */ -void scanSRV_restart (TI_HANDLE hScanSRV) -{ - scanSRV_t *pScanSRV = (scanSRV_t *)hScanSRV; - /* init state machine */ - /* initialize current state */ - pScanSRV->SMState = SCAN_SRV_STATE_IDLE; - - if (pScanSRV->bTimerRunning) - { - tmr_StopTimer (pScanSRV->hScanSrvTimer); - pScanSRV->bTimerRunning = TI_FALSE; - } -} - -/** - * \\n - * \date 26-July-2006\n - * \brief Configures the scan SRV module with initialization values - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param hReport - handle to the report object.\n - * \param hTWD - handle to the HAL ctrl object.\n - */ -void MacServices_scanSrv_config( TI_HANDLE hMacServices, TScanSrvInitParams* pInitParams ) -{ - MacServices_t* pMacServices = (MacServices_t*)hMacServices; - scanSRV_t *pScanSRV = pMacServices->hScanSRV; - - pScanSRV->numberOfNoScanCompleteToRecovery = pInitParams->numberOfNoScanCompleteToRecovery; - - /* Set Triggered scan time out per channel */ - pScanSRV->uTriggeredScanTimeOut = pInitParams->uTriggeredScanTimeOut; - TWD_CmdSetSplitScanTimeOut (pScanSRV->hTWD, pScanSRV->uTriggeredScanTimeOut); -} - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Registers a complete callback for scan complete notifications. - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param scanCompleteCB - the complete callback function.\n - * \param hScanCompleteObj - handle to the object passed to the scan complete callback function.\n - */ -void MacServices_scanSRV_registerScanCompleteCB( TI_HANDLE hMacServices, - TScanSrvCompleteCb scanCompleteCB, TI_HANDLE hScanCompleteObj ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV; - - pScanSRV->scanCompleteNotificationFunc = scanCompleteCB; - pScanSRV->scanCompleteNotificationObj = hScanCompleteObj; -} - -/** - * \brief Registers a failure event callback for scan error notifications. - * - * Function Scope \e member.\n - * \param hScanSRV - handle to the Scan SRV object.\n - * \param failureEventCB - the failure event callback function.\n - * \param hFailureEventObj - handle to the object passed to the failure event callback function.\n - */ -void scanSRV_registerFailureEventCB( TI_HANDLE hScanSRV, - void * failureEventCB, TI_HANDLE hFailureEventObj ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)(hScanSRV); - - pScanSRV->failureEventFunc = (TFailureEventCb)failureEventCB; - pScanSRV->failureEventObj = hFailureEventObj; -} - -/** - * \\n - * \date 27-Sep-2005\n - * \brief This function is the CB which is called as response to 'StartScan' or 'StopScan' \n. - * here we check if there is a GWSI command response , and call it if necessary .\n - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \param MboxStatus - mailbox status. \n - */ -void MacServices_scanSRVCommandMailBoxCB(TI_HANDLE hScanSrv,TI_UINT16 MboxStatus) -{ - scanSRV_t* pScanSRV = (scanSRV_t*)hScanSrv; - TI_UINT16 responseStatus; - TCmdResponseCb CB_Func; - TI_HANDLE CB_Handle; - - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, " status %u\n",MboxStatus); - - /* set response to TI_OK or TI_NOK */ - responseStatus = ((MboxStatus > 0) ? TI_NOK : TI_OK); - - /* if we have a Response Function (only in GWSI) we set it back to NULL and then - we call it */ - if (pScanSRV->commandResponseFunc != NULL) - { - CB_Func = pScanSRV->commandResponseFunc; - CB_Handle = pScanSRV->commandResponseObj; - - pScanSRV->commandResponseFunc = NULL; - pScanSRV->commandResponseObj = NULL; - - CB_Func(CB_Handle, responseStatus); - } - /* if scan request failed */ - if ( TI_OK != responseStatus ) - { - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_ERROR, "Mail box returned error , quitting scan.\n"); - - /* send a scan complete event. This will do all necessary clean-up (timer, power manager, notifying scan complete) */ - scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_SCAN_COMPLETE ); - } -} - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Performs a scan - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param scanParams - the scan specific parameters.\n - * \param eScanresultTag - tag used for result and scan complete tracking - * \param bHighPriority - whether to perform a high priority (overlaps DTIM) scan.\n - * \param bDriverMode - whether to try to enter driver mode (with PS on) before issuing the scan command.\n - * \param bScanOnDriverModeError - whether to proceed with the scan if requested to enter driver mode and failed.\n - * \param psRequest - Parameter sent to PowerSaveServer on PS request to indicate PS on or "keep current" - * \param bSendNullData - whether to send Null data when exiting driver mode on scan complete.\n - * \param commandResponseFunc - CB function which called after downloading the command. \n - * \param commandResponseObj - The CB function Obj (Notice : last 2 params are NULL in Legacy run). \n - * \param psRequest - Parameter sent to PowerSaveServer on PS request to indicate PS on or "keep current" - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_scanSRV_scan( TI_HANDLE hMacServices, TScanParams *scanParams, EScanResultTag eScanTag, - TI_BOOL bHighPriority, TI_BOOL bDriverMode, TI_BOOL bScanOnDriverModeError, - E80211PsMode psRequest, TI_BOOL bSendNullData, - TCmdResponseCb commandResponseFunc, TI_HANDLE commandResponseObj) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV; - - - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Scan request received.\n"); - - /* sanity check - scan can only start if the scan SRV is idle */ - if ( SCAN_SRV_STATE_IDLE != pScanSRV->SMState ) - { - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_WARNING, "Scan request while scan is running!\n"); - return TI_NOK; - } - - /* Response function for GWSI only. In Legacy run we get NULL and never use it. */ - pScanSRV->commandResponseFunc = commandResponseFunc; - pScanSRV->commandResponseObj = commandResponseObj; - - pScanSRV->bInRequest = TI_TRUE; - pScanSRV->returnStatus = TI_OK; - - /* copy scan paramaters */ - pScanSRV->scanParams = scanParams; - pScanSRV->eScanTag = eScanTag; - pScanSRV->uResultCount = 0; - pScanSRV->bHighPriority = bHighPriority; - pScanSRV->bScanOnDriverModeFailure = bScanOnDriverModeError; - pScanSRV->bSendNullData = bSendNullData; - pScanSRV->psRequest = psRequest; - - if ( SCAN_TYPE_SPS == scanParams->scanType ) - { - pScanSRV->bSPSScan = TI_TRUE; - - } - else - { - pScanSRV->bSPSScan = TI_FALSE; - } - - - /* check whether the scan will overlap DTIM frame */ - if ( (TI_FALSE == bHighPriority) && (TI_TRUE == bDriverMode)) - { - pScanSRV->bDtimOverlapping = TI_FALSE; - } - else - { - pScanSRV->bDtimOverlapping = TI_TRUE; - } - - /* mark the no scan complete flag. The purpose of this flag is to be able to identify - whether the scan complete is a normal process, or was it generated because a no scan ocmplete - was identified, a stop scan command was snet to the FW, and thus a scan complete was received. - In the former case we nullify the consecutive no scan complete counter, whereas in the latter - we do not. */ - pScanSRV->bNoScanCompleteFlag = TI_FALSE; - - /* if required to enter driver mode */ - if ( TI_TRUE == bDriverMode ) - { - pScanSRV->bExitFromDriverMode = TI_TRUE; - /* send a PS_REQUEST event */ - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&(pScanSRV->SMState), SCAN_SRV_EVENT_REQUEST_PS ); - } - /* no driver mode required */ - else - { - pScanSRV->bExitFromDriverMode = TI_FALSE; - /* send a PS_SUCCESS event - will start the scan */ - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS ); - } - - pScanSRV->bInRequest = TI_FALSE; - - return pScanSRV->returnStatus; -} - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Sends a Stop Scan command to FW, no matter if we are in scan progress or not - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param eScanTag - scan tag, used for scan complete and result tracking - * \param bSendNullData - indicates whether to send Null data when exiting driver mode.\n - * \param commandResponseFunc - CB function which called after downloading the command. \n - * \param commandResponseObj - The CB function Obj (Notice : last 2 params are NULL in Legacy run). \n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_scanSRV_stopScan( TI_HANDLE hMacServices, EScanResultTag eScanTag, TI_BOOL bSendNullData, - TCmdResponseCb ScanCommandResponseCB, TI_HANDLE CB_handle ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV; - TI_INT32 stopScanStatus; - - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Stop scan request received.\n"); - - /* update the driver mode exit flag */ - pScanSRV->bSendNullData = bSendNullData; - - if ( TI_TRUE == pScanSRV->bSPSScan ) - { - stopScanStatus = cmdBld_CmdStopSPSScan (pScanSRV->hCmdBld, eScanTag, (void *)ScanCommandResponseCB, CB_handle); - } - else - { - stopScanStatus = cmdBld_CmdStopScan (pScanSRV->hCmdBld, eScanTag, (void *)ScanCommandResponseCB, CB_handle); - } - - if (TI_OK != stopScanStatus) - { - return TI_NOK; - } - - /* send a stop scan event */ - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_STOP_SCAN ); - - return pScanSRV->returnStatus; -} - -/** - * \\n - * \date 17-Jan-2005\n - * \brief Notifies the scan SRV of a FW reset (that had originally been reported by a different module).\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \return TI_OK if successful (various, TBD codes if not).\n - */ -TI_STATUS MacServices_scanSRV_stopOnFWReset( TI_HANDLE hMacServices ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV; - - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "FW reset notification received.\n"); - - /* mark the return status */ - pScanSRV->returnStatus = TI_NOK; - - /* send a FW reset event */ - return scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_FW_RESET ); -} - -/** - * \\n - * \date 29-Dec-2004\n - * \brief callback function used by the power server to notify driver mode result - * this CB is used in requesting PS and exiting PS. - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param psStatus - the power save request status.\n - */ -void MacServices_scanSRV_powerSaveCB( TI_HANDLE hScanSRV, TI_UINT8 PSMode,TI_UINT8 psStatus ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV; - - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "PS Call Back status %d .\n",psStatus); - - /* if driver mode enter/exit succeedded */ - if ( (ENTER_POWER_SAVE_SUCCESS == psStatus) || (EXIT_POWER_SAVE_SUCCESS == psStatus)) - { - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "PS successful.\n"); - - /* send a PS_SUCCESS event */ - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS ); - } - /* driver mode entry failed, and scan is requested even on PS failure but we are entering PS and not Exiting */ - else if ( (TI_TRUE == pScanSRV->bScanOnDriverModeFailure) && ( ENTER_POWER_SAVE_FAIL == psStatus)) - { - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "PS enter failed, continune scan .\n"); - - /* send a PS_SUCCESS event */ - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS ); - } - /* driver mode enter or exit failed */ - else - { - /* if we are trying to enter PS and fail to do so - return error on scan complete */ - if ( ENTER_POWER_SAVE_FAIL == psStatus) - { - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_WARNING, "PS enter failed . quiting scan .\n"); - /* Set the return status */ - pScanSRV->returnStatus = TI_NOK; - } - - /* send a PS FAIL event */ - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_FAIL ); - } -} - - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Callback function used by the HAL ctrl to notify scan complete - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param str - pointer to scan result buffer (holding SPS status for SPS scan only!).\n - * \param strLen - scan result buffer length (should ALWAYS be 2, even for non SPS scans).\n - */ -void MacServices_scanSRV_scanCompleteCB( TI_HANDLE hScanSRV, char* str, TI_UINT32 strLen ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV; - scanCompleteResults_t *pResult = (scanCompleteResults_t*)str; - - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Scan complete notification from TNET.\n"); - - /* nullify the consecutive no scan complete events counter - only if this is a scan complete that - does not happen afetr a stop scan (due to a timer expiry) */ - if ( TI_FALSE == pScanSRV->bNoScanCompleteFlag ) - { - pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents = 0; - } - - /* copy result counter and scan tag */ - pScanSRV->uResultCount = pResult->numberOfScanResults; - pScanSRV->eScanTag = (EScanResultTag)pResult->scanTag; - - /* copy scan SPS addmitted channels and SPS result */ - if (TI_FALSE == pScanSRV->bSPSScan) - { - /* normal scan - no result is available */ - pScanSRV->bTSFError = TI_FALSE; - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Normal scan completed.\n"); - } - else - { - /* SPS scan - first byte indicates whether a TSF error (AP recovery) occured */ - if ( 0 != (pResult->scheduledScanStatus >> 24)) - { - pScanSRV->bTSFError = TI_TRUE; - } - else - { - pScanSRV->bTSFError = TI_FALSE; - } - - /* next two bytes indicates on which channels scan was attempted */ - pScanSRV->SPSScanResult = (TI_UINT16)(pResult->scheduledScanStatus >> 16) | 0xff; - pScanSRV->SPSScanResult = ENDIAN_HANDLE_WORD( pScanSRV->SPSScanResult ); - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "SPS scan completed. TSF error: , SPS result: %x\n", pScanSRV->SPSScanResult); - } - - /* send a SCAN_COMPLETE event */ - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_SCAN_COMPLETE ); -} - -/** - * \\n - * \date 29-Dec-2004\n - * \brief called when a scan timer expires. Completes the scan and starts a recovery process. - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started.\n - */ -void MacServices_scanSRV_scanTimerExpired (TI_HANDLE hScanSRV, TI_BOOL bTwdInitOccured) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV; - - /* mark that no scan complete occured (see sanSRV_scan for more detailed explanation) */ - pScanSRV->bNoScanCompleteFlag = TI_TRUE; - - /* send a TIMER_EXPIRED event */ - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_TIMER_EXPIRED ); -} - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Calculates the maximal time required for a scan operation - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param scanParams - the scan parameters - * \param bConsiderDTIM - whether this scan overlaps DTIM - * \return the time (in milliseconds) - */ -TI_UINT32 MacServices_scanSRVcalculateScanTimeout( TI_HANDLE hScanSRV, TScanParams* scanParams, TI_BOOL bConsiderDTIM ) -{ - TI_UINT32 i, uDtimPeriodMs, uBeaconIntervalMs, timeout = 0; - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV; - - /******************************************************************************** - timeout calculation is performed according to scan type: - 1. for normal scan, multiply the channel time by the number of channels. - if this scan is not overlapping DTIM, add the DTIM period (in case - starting the scan right now will cause the very last milliseconds of the - scan to overlap the next DTIM). Add the guard time. - 2. for triggered scan, multiply the channel time plus the trigger time - constant (the maximum time between two frames from the Tid - according to which the scan is triggered) by the number of channels. - DTIM period is added only as precaution - since the scan is divided to - channels, only very few of them will be delayed due to DTIM (in the worst - case), and this delay would be only the length of one channel scan. - Eventually, Add the guard time. - 3. for SPS scan: Measure the time from current TSF to the TSF at which the - scan is scheduled to finish (done by the scan manager, and passed as - a parameter in the scan structure). Add guard time. DTIM overlapping is not - considered because if the scan overlaps DTIM the channels which are - scheduled during the DTIM (if any) won't be scanned. - ********************************************************************************/ - - /* get DTIM time, if scanning in connected mode and need to consider DTIM */ - if ( bConsiderDTIM ) - { - /* new dtimPeriod calculation */ - uBeaconIntervalMs = MacServices_scanSRVConvertTUToMsec (pScanSRV->uBeaconInterval); - uDtimPeriodMs = uBeaconIntervalMs * pScanSRV->uDtimPeriod; - } - else - { - uDtimPeriodMs = 0; - } - - switch (scanParams->scanType) - { - case SCAN_TYPE_NORMAL_ACTIVE: - case SCAN_TYPE_NORMAL_PASSIVE: - /* the timeout is the scan duration on all channels */ - for ( i = 0; i < scanParams->numOfChannels; i++ ) - { - timeout += scanParams->channelEntry[ i ].normalChannelEntry.maxChannelDwellTime; - } - timeout = (timeout / 1000) + uDtimPeriodMs + SCAN_SRV_FW_GUARD_TIME_MS; - break; - - case SCAN_TYPE_TRIGGERED_ACTIVE: - case SCAN_TYPE_TRIGGERED_PASSIVE: - /* the timeout is the scan duration on all channels, plus the maximum time that can pass - between two different frames from the same Tid */ - for ( i = 0; i < scanParams->numOfChannels; i++ ) - { - timeout += scanParams->channelEntry[ i ].normalChannelEntry.maxChannelDwellTime; - } - timeout = (timeout / 1000) + uDtimPeriodMs + - ((pScanSRV->uTriggeredScanTimeOut / 1000 + 1) * scanParams->numOfChannels) + - SCAN_SRV_FW_GUARD_TIME_MS; - break; - - case SCAN_TYPE_SPS: - timeout = scanParams->SPSScanDuration + SCAN_SRV_FW_GUARD_TIME_MS; - break; - - default: - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_ERROR, "Trying to calculate timeout for undefined scan type %d\n", scanParams->scanType); - break; - } - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "scanSRVcalculateScanTimeout, timeout = %d\n", timeout); - - return timeout; -} - -/** - * \\n - * \date 16-Jan-2005\n - * \brief Convert time units (1024 usecs) to millisecs - * - * Function Scope \e Private.\n - * \param tu - the time in time units - * \return the time in milliseconds - */ -TI_UINT32 MacServices_scanSRVConvertTUToMsec( TI_UINT32 tu ) -{ - return (tu * 1024) / 1000; -} - - -/** - * \\n - * \brief Save DTIM and Beacon periods for scan timeout calculations - * - * Function Scope \e Public.\n - * \param hMacServices - module object - * \param uDtimPeriod - DTIM period in number of beacons - * \param uBeaconInterval - Beacon perios in TUs (1024 msec) - * \return void - */ -void MacServices_scanSrv_UpdateDtimTbtt (TI_HANDLE hMacServices, - TI_UINT8 uDtimPeriod, - TI_UINT16 uBeaconInterval) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV; - - pScanSRV->uDtimPeriod = uDtimPeriod; - pScanSRV->uBeaconInterval = uBeaconInterval; -} - - -#ifdef TI_DBG -/** - * \\n - * \date God knows when...\n - * \brief Prints Scan Server SM status.\n - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the Mac Services object.\n - * \return always TI_OK.\n - */ -void MacServices_scanSrv_printDebugStatus(TI_HANDLE hMacServices) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV; - - WLAN_OS_REPORT(("scanSrv State=")); - switch (pScanSRV->SMState) - { - case SCAN_SRV_STATE_IDLE: - WLAN_OS_REPORT((" IDLE\n")); - break; - case SCAN_SRV_STATE_PS_WAIT: - WLAN_OS_REPORT((" PS_WAIT\n")); - break; - case SCAN_SRV_STATE_PS_EXIT: - WLAN_OS_REPORT((" PS_EXIT\n")); - break; - case SCAN_SRV_STATE_SCANNING: - WLAN_OS_REPORT((" SCANNING\n")); - break; - case SCAN_SRV_STATE_STOPPING: - WLAN_OS_REPORT((" STOPPING\n")); - break; - default: - WLAN_OS_REPORT((" Invalid State=%d\n",pScanSRV->SMState)); - break; - - } - - if (NULL != pScanSRV->scanParams) - { - WLAN_OS_REPORT(("scanSrv bExitFromDriverMode=%d, bHighPriority=%d, bInRequest=%d,\n \ - bScanOnDriverModeFailure=%d, bSendNullData=%d, bSPSScan=%d, bTimerRunning=%d, \n \ - psRequest=%d, scanType=%d\n", - pScanSRV->bExitFromDriverMode, - pScanSRV->bHighPriority, - pScanSRV->bInRequest, - pScanSRV->bScanOnDriverModeFailure, - pScanSRV->bSendNullData, - pScanSRV->bSPSScan, - pScanSRV->bTimerRunning, - pScanSRV->psRequest, - pScanSRV->scanParams->scanType)); - } -} -#endif - diff --git a/wl1271/TWD/MacServices/ScanSrv.h b/wl1271/TWD/MacServices/ScanSrv.h deleted file mode 100644 index 3370cefb..00000000 --- a/wl1271/TWD/MacServices/ScanSrv.h +++ /dev/null @@ -1,308 +0,0 @@ -/* - * ScanSrv.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file ScanSrv.h - * \brief This file include private definitions for the scan SRV module. - * - * \see ScanSrv.c, ScanSrvSM.c, ScanSrvSM.h - */ - - -#ifndef __SCANSRV_H__ -#define __SCANSRV_H__ - -#include "TWDriverInternal.h" -#include "MacServices_api.h" -#include "fsm.h" -#include "ScanSrvSM.h" - -/* - *********************************************************************** - * Constant definitions. - *********************************************************************** - */ -/* guard time for scan (added to calculated scan duration) */ -#define SCAN_SRV_FW_GUARD_TIME_MS 62000 -/* module name for driver mode requests */ -#define SCAN_SRV_NAME "SSRV" - - -/* - *********************************************************************** - * Enums. - *********************************************************************** - */ - - -/* - *********************************************************************** - * Typedefs. - *********************************************************************** - */ - -/* - *********************************************************************** - * Structure definitions. - *********************************************************************** - */ - -/** \struct scanSRV_t - * \brief This structure contains the scan SRV object data - */ -typedef struct -{ - TI_HANDLE hOS; /**< OS object handle */ - TI_HANDLE hReport; /**< report object handle */ - TI_HANDLE hPowerSrv; /**< power Server object handle */ - TI_HANDLE hTWD; /**< TWD layer handle */ - TI_HANDLE hTimer; /**< Timer module object handle */ - TI_HANDLE hEventMbox; /**< EventMbox module object handle */ - TI_HANDLE hCmdBld; /**< Command builder object handle */ - TScanSrvCompleteCb scanCompleteNotificationFunc; /**< - * upper layer (scan concentrator) scan complete - * callback function - */ - TI_HANDLE scanCompleteNotificationObj; /**< - * upper layer (scan concentrator) scan complete - * callback function - */ - - TCmdResponseCb commandResponseFunc; /**< - * upper layer command response CB. Passed down into the HAL - * and called when the scan command has been received by the FW - */ - TI_HANDLE commandResponseObj; /**< - * object parameter passed to the commandResposeFunc by the HAL - * when it is called - */ - TFailureEventCb failureEventFunc; /**< - * upper layer Failure Event CB. - * called when the scan command has been Timer Expiry - */ - TI_HANDLE failureEventObj; /**< - * object parameter passed to the failureEventFunc - * when it is called - */ - TI_UINT16 SPSScanResult; /**< - * bitmap indicating which channels were scanned - * in an SPS scan - */ - TI_BOOL bTSFError; /** indicates whether a TSF error occured */ /**< - * scan result: indicates a TSF error event and - * which channels were scanned in SPS - */ - TI_BOOL bDtimOverlapping; /**< Indicates whether the scan is overlapping DTIM */ - TI_BOOL bExitFromDriverMode; /**< - * Indicates whether to exit driver mode once scan - * is finished - */ - TI_BOOL bSendNullData; /**< - * Indicates whether to send Null data when exiting driver - * mode once scan is finished - */ - TI_BOOL bScanOnDriverModeFailure; /**< - * Indicates whether to scan if driver mode entry - * wasn't successful - */ - TI_BOOL bHighPriority; /**< - * Indicates whether to request high priority - * (overlapping DTIM) scan - */ - TI_BOOL bSPSScan; /**< - * whether the running scan type is SPS (TI_TRUE) - * or something else (TI_FALSE). Used to stop a - * running scan. - */ - TScanParams* scanParams; /**< scan parameters */ - EScanResultTag eScanTag; /**< scan result tag */ - TI_UINT32 uResultCount; /**< number of scan results (received from the FW) */ - TI_HANDLE hScanSrvTimer; /**< scan operation timer */ - TI_BOOL bTimerRunning; /**< whether the above timer is running */ - TI_BOOL bInRequest; /**< - * Indicates whether the SM is run within - * the scan request context (if so, to avoid - * re-entrance, the complete function shouldn't - * be called on failure, but rather an invalid - * status should be returned) - */ - TI_STATUS returnStatus; /**< - * Holds the return code to the upper layer - * Used to save errors during SM operation. - */ - /* state machine */ - fsm_stateMachine_t* SM; /**< - * state machines for different - * scan types - */ - scan_SRVSMStates_e SMState; /**< - * state machine current states - * for different scan types - */ - E80211PsMode psRequest; /**< - * Indicates if PS was requested or not - * for current scan - */ - TI_UINT32 numberOfNoScanCompleteToRecovery; - /**< - * The number of consecutive no scan complete - * that will trigger a recovery notification - */ - TI_UINT32 currentNumberOfConsecutiveNoScanCompleteEvents; - /**< - * The number of consecutivre no scan complete - * events at present - */ - TI_BOOL bNoScanCompleteFlag; /**< - * Indicates if the last event was start scan - * (true) or no scan complete (false) to be able - * to nullify correctly the above counter */ - TI_UINT32 uTriggeredScanTimeOut; /**< - * Time out for starting triggered scan between - * 2 channels */ - TI_UINT8 uDtimPeriod; - TI_UINT16 uBeaconInterval; -} scanSRV_t; - -/* - *********************************************************************** - * External data definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External functions definitions - *********************************************************************** - */ - -/** - * \\n - * \date 16-Oct-2004\n - * \brief Creates the scan SRV object - * - * Function Scope \e Public.\n - * \param hOS - handle to the OS object.\n - * \return a handle to the scan SRV object, NULL if an error occurred.\n - */ -TI_HANDLE MacServices_scanSRV_create( TI_HANDLE hOS ); - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Finalizes the scan SRV module (releasing memory and timer) - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - */ -void MacServices_scanSRV_destroy( TI_HANDLE hScanSRV ); - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Initializes the scan SRV module, registers SCAN_COMPLETE to HAL. - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param Handles of other modules.\n - */ -TI_STATUS MacServices_scanSRV_init (TI_HANDLE hMacServices, - TI_HANDLE hReport, - TI_HANDLE hTWD, - TI_HANDLE hTimer, - TI_HANDLE hEventMbox, - TI_HANDLE hCmdBld); - -/** - * \\n - * \date 26-July-2006\n - * \brief Configures the scan SRV module with initialization values - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param hReport - handle to the report object.\n - * \param hHalCtrl - handle to the HAL ctrl object.\n - */ -void MacServices_scanSrv_config( TI_HANDLE hMacServices, TScanSrvInitParams* pInitParams ); - -/** - * \\n - * \date 29-Dec-2004\n - * \brief Calculates the maximal time required for a scan operation - * - * Function Scope \e Public.\n - * \param hScanSRV - handle to the scan SRV object.\n - * \param scanParams - the scan parameters - * \param bConsiderDTIM - whether this scan overlaps DTIM - * \return the time (in milliseconds) - */ -TI_UINT32 MacServices_scanSRVcalculateScanTimeout( TI_HANDLE hScanSrv, TScanParams* scanParams, TI_BOOL bConsiderDTIM ); - -/** - * \\n - * \date 16-Jan-2005\n - * \brief Convert time units (1024 usecs) to millisecs - * - * Function Scope \e Private.\n - * \param tu - the time in time units - * \return the time in milliseconds - */ -TI_UINT32 MacServices_scanSRVConvertTUToMsec( TI_UINT32 tu ); - -/** - * \\n - * \date 27-Sep-2005\n - * \brief This function is the CB which is called as response to 'StartScan' or 'StopScan' \n. - * here we check if there is a GWSI command response , and call it if necessary .\n - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \param MboxStatus - mailbox status. \n - */ - -void MacServices_scanSRVCommandMailBoxCB(TI_HANDLE hScanSrv,TI_UINT16 MboxStatus); - - -/** - * \brief Registers a failure event callback for scan error notifications. - * - * Function Scope \e Public.\n - * \param hMacServices - handle to the MacServices object.\n - * \param failureEventCB - the failure event callback function.\n - * \param hFailureEventObj - handle to the object passed to the failure event callback function.\n - */ -void scanSRV_registerFailureEventCB( TI_HANDLE hScanSRV, - void * failureEventCB, TI_HANDLE hFailureEventObj ); - -void scanSRV_restart( TI_HANDLE hScanSRV); - - -#endif /* __SCANSRV_H__ */ diff --git a/wl1271/TWD/MacServices/ScanSrvSM.c b/wl1271/TWD/MacServices/ScanSrvSM.c deleted file mode 100644 index 8d96feaa..00000000 --- a/wl1271/TWD/MacServices/ScanSrvSM.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - * ScanSrvSM.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file ScanSrvSM.c - * \brief This file include the scan SRV Sm implementation - * \author Ronen Kalish - * \date 10-Jan-2005 - */ - -#define __FILE_ID__ FILE_ID_116 -#include "ScanSrvSM.h" -#include "ScanSrv.h" -#include "report.h" -#include "timer.h" -#include "MacServices_api.h" -#include "PowerSrv_API.h" -#include "CmdBld.h" - - -/********************************************************************************/ -/* Internal functions prototypes. */ -/********************************************************************************/ - -static TI_STATUS scanSRVSM_PsFailWhileScanning( TI_HANDLE hScanSrv ); -static TI_STATUS actionNop( TI_HANDLE hScanSrv ); -static TI_STATUS actionUnexpected( TI_HANDLE hScanSrv ); - - -/********************************************************************************/ -/* Interface functions Implementation. */ -/********************************************************************************/ - - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Initialize the scan SRV SM. - * - * Function Scope \e Public.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_init( TI_HANDLE hScanSrv ) -{ - scanSRV_t* pScanSRV = (scanSRV_t*)hScanSrv; - - fsm_actionCell_t smMatrix[ SCAN_SRV_NUM_OF_STATES ][ SCAN_SRV_NUM_OF_EVENTS ] = - { - /* next state and actions for IDLE state */ - { - {SCAN_SRV_STATE_PS_WAIT, scanSRVSM_requestPS}, /*"REQUEST_PS",*/ - {SCAN_SRV_STATE_IDLE, actionUnexpected}, /*"PS_FAIL",*/ - {SCAN_SRV_STATE_SCANNING, scanSRVSM_startActualScan}, /*"PS_SUCCESS", */ - {SCAN_SRV_STATE_IDLE, actionUnexpected}, /*"PS_PEND",*/ - {SCAN_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_SCAN"*/ - {SCAN_SRV_STATE_IDLE, actionNop}, /*"FW_RESET"*/ - {SCAN_SRV_STATE_IDLE, actionUnexpected}, /*"TIMER_EXPIRED"*/ - {SCAN_SRV_STATE_IDLE, actionUnexpected}, /*"SCAN_COMPLETE"*/ - }, - - - /* next state and actions for PS_WAIT state */ - { - {SCAN_SRV_STATE_PS_WAIT, actionUnexpected}, /*"REQUEST_PS",*/ - {SCAN_SRV_STATE_PS_EXIT, scanSRVSM_releasePS}, /*"PS_FAIL",*/ - {SCAN_SRV_STATE_SCANNING, scanSRVSM_startActualScan}, /*"PS_SUCCESS", */ - {SCAN_SRV_STATE_PS_WAIT, actionNop}, /*"PS_PEND",*/ - {SCAN_SRV_STATE_STOPPING, actionNop}, /*"STOP_SCAN"*/ - {SCAN_SRV_STATE_IDLE, scanSRVSM_handleRecovery}, /*"FW_RESET"*/ - {SCAN_SRV_STATE_PS_WAIT, actionUnexpected}, /*"TIMER_EXPIRED"*/ - {SCAN_SRV_STATE_PS_WAIT, actionUnexpected}, /*"SCAN_COMPLETE"*/ - }, - - /* next state and actions for SCANNING state */ - { - {SCAN_SRV_STATE_SCANNING, actionUnexpected}, /*"REQUEST_PS",*/ - {SCAN_SRV_STATE_SCANNING, scanSRVSM_PsFailWhileScanning}, /*"PS_FAIL",*/ - {SCAN_SRV_STATE_SCANNING, actionUnexpected}, /*"PS_SUCCESS", */ - {SCAN_SRV_STATE_SCANNING, actionUnexpected}, /*"PS_PEND",*/ - {SCAN_SRV_STATE_STOPPING, actionNop }, /*"STOP_SCAN"*/ - {SCAN_SRV_STATE_IDLE, scanSRVSM_handleRecovery}, /*"FW_RESET"*/ - {SCAN_SRV_STATE_SCANNING, scanSRVSM_handleTimerExpiry}, /*"TIMER_EXPIRED"*/ - {SCAN_SRV_STATE_PS_EXIT, scanSRVSM_releasePS}, /*"SCAN_COMPLETE"*/ - - }, - - /* next state and actions for STOPPING state */ - { - {SCAN_SRV_STATE_STOPPING, actionUnexpected}, /*"REQUEST_PS",*/ - {SCAN_SRV_STATE_PS_EXIT, scanSRVSM_releasePS}, /*"PS_FAIL",*/ - {SCAN_SRV_STATE_PS_EXIT, scanSRVSM_releasePS}, /*"PS_SUCCESS", */ - {SCAN_SRV_STATE_STOPPING, actionUnexpected}, /*"PS_PEND",*/ - {SCAN_SRV_STATE_STOPPING, actionNop }, /*"STOP_SCAN"*/ - {SCAN_SRV_STATE_IDLE, scanSRVSM_handleRecovery}, /*"FW_RESET"*/ - {SCAN_SRV_STATE_STOPPING, scanSRVSM_handleTimerExpiry}, /*"TIMER_EXPIRED"*/ - {SCAN_SRV_STATE_PS_EXIT, scanSRVSM_releasePS} /*"SCAN_COMPLETE"*/ - - } , - - /* next state and actions for PS_EXIT state */ - { - {SCAN_SRV_STATE_PS_EXIT, actionUnexpected}, /*"REQUEST_PS",*/ - {SCAN_SRV_STATE_IDLE, scanSRVSM_notifyScanComplete}, /*"PS_FAIL",*/ - {SCAN_SRV_STATE_IDLE, scanSRVSM_notifyScanComplete}, /*"PS_SUCCESS", */ - {SCAN_SRV_STATE_PS_EXIT, actionNop}, /*"PS_PEND",*/ - {SCAN_SRV_STATE_PS_EXIT, actionNop}, /*"STOP_SCAN"*/ - {SCAN_SRV_STATE_IDLE, scanSRVSM_handleRecovery}, /*"FW_RESET"*/ - {SCAN_SRV_STATE_PS_EXIT, actionUnexpected}, /*"TIMER_EXPIRED"*/ - {SCAN_SRV_STATE_PS_EXIT, actionUnexpected}, /*"SCAN_COMPLETE"*/ - } - }; - - /* initialize current state */ - pScanSRV->SMState = SCAN_SRV_STATE_IDLE; - - /* configure the state machine */ - return fsm_Config( pScanSRV->SM, (fsm_Matrix_t)smMatrix, - (TI_UINT8)SCAN_SRV_NUM_OF_STATES, (TI_UINT8)SCAN_SRV_NUM_OF_EVENTS, - (fsm_eventActivation_t)scanSRVSM_SMEvent, pScanSRV->hOS ); -} - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Processes an event. - * - * Function Scope \e Public.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \param currentState - the current scan SRV SM state.\n - * \param event - the event to handle.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_SMEvent( TI_HANDLE hScanSrv, scan_SRVSMStates_e* currentState, - scan_SRVSMEvents_e event ) -{ - scanSRV_t *pScanSRV = (scanSRV_t *)hScanSrv; - TI_STATUS status = TI_OK; - TI_UINT8 nextState; - - /* obtain the next state */ - status = fsm_GetNextState( pScanSRV->SM, *(TI_UINT8*)currentState, (TI_UINT8)event, &nextState ); - if ( status != TI_OK ) - { - TRACE2(pScanSRV->hReport, REPORT_SEVERITY_ERROR, "Failed getting scan SRV next state. state = %d event = %d\n", (TI_UINT8)*currentState,(TI_UINT8)event); - return TI_NOK; - } - - TRACE3(pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "scanSRVSM_SMEvent: <currentState = %d, event = %d> --> nextState = %d\n", *currentState, event, nextState); - - /* move */ - return fsm_Event( pScanSRV->SM, (TI_UINT8*)currentState, (TI_UINT8)event, hScanSrv ); -} - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Request to enter driver mode from the power manager module.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_requestPS( TI_HANDLE hScanSrv ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv; - TI_STATUS psStatus; - - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Requesting Driver mode from PowerSave Srv.\n"); - - psStatus = powerSrv_ReservePS( pScanSRV->hPowerSrv, - pScanSRV->psRequest, - pScanSRV->bSendNullData, - hScanSrv, - MacServices_scanSRV_powerSaveCB); - - switch (psStatus) - { - /* if successful */ - case POWER_SAVE_802_11_IS_CURRENT: - /* send a PS_SUCCESS event */ - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Driver mode successful, continuing to scan.\n"); - return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS ); - - /* if pending */ - case POWER_SAVE_802_11_PENDING: - case TI_OK: - /* send a PS_PEND event */ - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Driver mode pending, Waiting.\n"); - return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_PEND ); - - /* if not successful */ - default: - - /* mark not to exit from driver mode (no entry was performed) */ - pScanSRV->bExitFromDriverMode = TI_FALSE; - - /* if still wishing to scan */ - if ( pScanSRV->bScanOnDriverModeFailure ) - { - /* send a PS_SUCCESS event - scan will proceed regardless of the error */ - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Driver mode failed, continuing to scan.\n"); - scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS ); - } - /* otherwise, return */ - else - { - /* mark the return code */ - pScanSRV->returnStatus = TI_NOK; - /* send a PS_FAIL event */ - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Driver mode failed, aborting scan.\n"); - scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_FAIL ); - } - break; - } - - return TI_OK; -} - -/** - * \author Yuval Adler\n - * \date 6-Oct-2005\n - * \brief Request to release PS mode from the PowerSRV , and wait for answer.\n\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ - -TI_STATUS scanSRVSM_releasePS( TI_HANDLE hScanSrv ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv; - TI_STATUS psStatus; - - /* stop timer */ - if ( TI_TRUE == pScanSRV->bTimerRunning ) - { - tmr_StopTimer (pScanSRV->hScanSrvTimer); - pScanSRV->bTimerRunning = TI_FALSE; - } - - /* if exit from driver mode requested, do so */ - if ( TI_TRUE == pScanSRV->bExitFromDriverMode ) - { - /* here we need to get an answer if we succeeded to exit driver mode */ - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Releasing Driver mode from Power Srv.\n"); - - psStatus = powerSrv_ReleasePS( pScanSRV->hPowerSrv, - pScanSRV->bSendNullData, - hScanSrv, - MacServices_scanSRV_powerSaveCB); - - - } - else /* no need to exit PS - send PS_SUCCESS */ - { - return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS ); - } - - - switch (psStatus) - { - /* if successful */ - case POWER_SAVE_802_11_IS_CURRENT: - /* send a PS_SUCCESS event */ - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Driver mode exit successful, scan done.\n"); - return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS ); - - /* if pending */ - case POWER_SAVE_802_11_PENDING: - case TI_OK: - /* stay in the PS_EXIT state */ - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Driver mode exit pending, Waiting.\n"); - break; - - /* if not successful */ - default: - - /* send a PS_FAIL event */ - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Driver mode exit failed, scan done."); - return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_FAIL ); - - } - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Send the scan command to the firmware.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_startActualScan( TI_HANDLE hScanSrv ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv; - - - /* start the timer */ - pScanSRV->bTimerRunning = TI_TRUE; - tmr_StartTimer (pScanSRV->hScanSrvTimer, - MacServices_scanSRV_scanTimerExpired, - (TI_HANDLE)pScanSRV, - MacServices_scanSRVcalculateScanTimeout (hScanSrv, pScanSRV->scanParams, !pScanSRV->bDtimOverlapping), - TI_FALSE); - - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Sending scan , type: %x to HAL.\n",pScanSRV->scanParams->scanType); - - /* start the scan */ - /* we send the MacServices_scanSRVCommandMailBoxCB to be called when this command is recieved */ - if ( SCAN_TYPE_SPS == pScanSRV->scanParams->scanType ) - { - pScanSRV->returnStatus = cmdBld_CmdStartSPSScan (pScanSRV->hCmdBld, pScanSRV->scanParams, pScanSRV->eScanTag, - (void *)MacServices_scanSRVCommandMailBoxCB, hScanSrv); - } - else - { - pScanSRV->returnStatus = cmdBld_CmdStartScan (pScanSRV->hCmdBld, pScanSRV->scanParams, pScanSRV->eScanTag, - pScanSRV->bHighPriority , (void *)MacServices_scanSRVCommandMailBoxCB, - hScanSrv); - } - /* if scan request failed */ - if ( TI_OK != pScanSRV->returnStatus ) - { - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_ERROR, "HAL returned code %d for scan request, quitting scan.\n", pScanSRV->returnStatus); - - /* send a scan complete event. This will do all necessary clean-up (timer, power manager, notifying scan complete) */ - scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_SCAN_COMPLETE ); - } - - return TI_OK; -} - - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Notifies scan complete to upper layer.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_notifyScanComplete( TI_HANDLE hScanSrv ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv; - TCmdResponseCb CB_Func; - TI_HANDLE CB_Handle; - TI_STATUS PSMode; - - /* call the scan complete CB - only if not currently running from within a request context! */ - if ( TI_FALSE == pScanSRV->bInRequest ) - { - /* this means that ResponseFunc was not called yet , so we call it before ScanComplete */ - if (pScanSRV->commandResponseFunc) - { - /* must erase CB function before calling it to enable nested scans */ - CB_Func = pScanSRV->commandResponseFunc; - CB_Handle = pScanSRV->commandResponseObj; - - pScanSRV->commandResponseFunc = NULL; - pScanSRV->commandResponseObj = NULL; - - /* if we reached here than response status was TI_OK */ - CB_Func(CB_Handle, TI_OK); - - } - /* if function returns TI_TRUE than we are in PS mode , else - not */ - PSMode = powerSrv_getPsStatus(pScanSRV->hPowerSrv) ? POWER_SAVE_802_11_SUCCESS : POWER_SAVE_802_11_FAIL; - - TRACE2( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "scanSRVSM_notifyScanComplete status = 0x%x PSMode = 0x%x\n",pScanSRV->returnStatus,PSMode); - - - TRACE0(pScanSRV->hReport, REPORT_SEVERITY_INFORMATION , "scanSRVSM_notifyScanComplete: call TWD_OWN_EVENT_SCAN_CMPLT CB. In std MacServices_scanSRV_scanCompleteCB()\n"); - - pScanSRV->scanCompleteNotificationFunc( pScanSRV->scanCompleteNotificationObj, - pScanSRV->eScanTag, - pScanSRV->uResultCount, - pScanSRV->SPSScanResult, - pScanSRV->bTSFError, - pScanSRV->returnStatus, - PSMode ); - } - - return TI_OK; -} - - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Handles a timer expiry event - starts a recovery process. - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_handleTimerExpiry( TI_HANDLE hScanSrv ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv; - - /* - * No scan complete bug workaround: - * Only after a consecutive configurable number of no scan complete events the recovery trigger - * will be issued. This is done as a workaround for a bug in the FW where if a channel is too - * loaded it wouldn't be able to send a probe request and will get stuck waiting for this channel - */ - - pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents++; - - if ( pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents >= - pScanSRV->numberOfNoScanCompleteToRecovery ) - { - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_ERROR, ": Timer expired. Starting recovery process.\n"); - - pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents = 0; - - /* mark the return status */ - pScanSRV->returnStatus = TI_NOK; - - /* mark that the timer is no longer running */ - pScanSRV->bTimerRunning = TI_FALSE; - - /* call the recovery module */ - pScanSRV->failureEventFunc(pScanSRV->failureEventObj ,NO_SCAN_COMPLETE_FAILURE); - } - else - { - TRACE2( pScanSRV->hReport, REPORT_SEVERITY_ERROR, ": Timer expired. consecutive failures:%d, threshold:%d, still not calling recovery.\n", pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents, pScanSRV->numberOfNoScanCompleteToRecovery); - - /* send a top scan command, which can help solving the FW bug described above */ - if ( TI_FALSE == pScanSRV->bSPSScan ) - { - cmdBld_CmdStopScan (pScanSRV->hCmdBld, pScanSRV->eScanTag, NULL, NULL); - } - else - { - cmdBld_CmdStopSPSScan (pScanSRV->hCmdBld, pScanSRV->eScanTag, NULL, NULL); - } - - /* imitate a scan complete event to the SM */ - pScanSRV->bTSFError = TI_FALSE; - pScanSRV->SPSScanResult = 0xffff; - scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_SCAN_COMPLETE ); - } - - return TI_OK; -} - -/** - * \author Shirit Brook\n - * \date 10-Jan-2005\n - * \brief Handles PS Fail event while in Scanning - Indicate not to Exit PS. - * This event can be reached when Roaming is invoked while in Scanning state. - * The PM Module is stopped and generates PS Fail to all its clients. - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -static TI_STATUS scanSRVSM_PsFailWhileScanning( TI_HANDLE hScanSrv ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv; - - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "scanSRVSM_PsFailWhileScanning. Indicate not to Enter PS.\n"); - - pScanSRV->bExitFromDriverMode = TI_FALSE; - - return TI_OK; -} - - -/** - * \author Ronen Kalish\n - * \date 17-Jan-2005\n - * \brief Handles a FW reset event (one that was detected outside the scan SRV) by stopping the timer. - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_handleRecovery( TI_HANDLE hScanSrv ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv; - - TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "FW reset event from outside.\n"); - - /* The Power Manager is responsible to exit PS mode in recovery. Also, the scan CB is not called - - The SCR is responsible to notify scan concentrator of the event (which actually notifies scan SRV */ - - /* if timer is running - stop it */ - if ( TI_TRUE == pScanSRV->bTimerRunning ) - { - tmr_StopTimer (pScanSRV->hScanSrvTimer); - pScanSRV->bTimerRunning = TI_FALSE; - } - else - { - /* shouldn't happen - only called if timer is supposedly running */ - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_WARNING, "SM: External FW reset in state %d and timer is not running?", pScanSRV->SMState); - } - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 11-Jan-2005\n - * \brief Handles an unexpected event.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return always TI_OK.\n - */ -static TI_STATUS actionUnexpected( TI_HANDLE hScanSrv ) -{ - scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv; - - TRACE1( pScanSRV->hReport, REPORT_SEVERITY_ERROR, "Scan SRV state machine error, unexpected Event, state=%d\n\n", pScanSRV->SMState); - - if ( pScanSRV->bTimerRunning ) - { - tmr_StopTimer (pScanSRV->hScanSrvTimer); - pScanSRV->bTimerRunning = TI_FALSE; - } - - /* we must clean the old command response CB since they are no longer relevant - since the state machine may be corrupted */ - pScanSRV->commandResponseFunc = NULL; - pScanSRV->commandResponseObj = NULL; - - /* indicate the unexpected event in the return status */ - pScanSRV->returnStatus = TI_NOK; - - return TI_OK; -} - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Handles an event that doesn't require any action.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return always TI_OK.\n - */ -static TI_STATUS actionNop( TI_HANDLE hScanSrv ) -{ - return TI_OK; -} - - diff --git a/wl1271/TWD/MacServices/ScanSrvSM.h b/wl1271/TWD/MacServices/ScanSrvSM.h deleted file mode 100644 index 0b87e9fe..00000000 --- a/wl1271/TWD/MacServices/ScanSrvSM.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * ScanSrvSM.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file ScanSrvSM.h - * \brief This file include definitions for the scan SRV SM module. - * \author Ronen Kalish - * \date 10-Jan-2005 - */ - -#ifndef __SCANSRVSM_H__ -#define __SCANSRVSM_H__ - -#include "fsm.h" - -/* - *********************************************************************** - * Constant definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * Enums. - *********************************************************************** - */ - -/** \enum scan_SRVSMEvents_e - * \brief enumerates the different scan SRV SM events - */ -typedef enum -{ - SCAN_SRV_EVENT_REQUEST_PS = 0, - SCAN_SRV_EVENT_PS_FAIL, - SCAN_SRV_EVENT_PS_SUCCESS, - SCAN_SRV_EVENT_PS_PEND, - SCAN_SRV_EVENT_STOP_SCAN, - SCAN_SRV_EVENT_FW_RESET, - SCAN_SRV_EVENT_TIMER_EXPIRED, - SCAN_SRV_EVENT_SCAN_COMPLETE, - SCAN_SRV_NUM_OF_EVENTS -} scan_SRVSMEvents_e; - -/** \enum scan_SRVSMStates_e - * \brief enumerates the different scan SRV SM states - */ -typedef enum -{ - SCAN_SRV_STATE_IDLE = 0, - SCAN_SRV_STATE_PS_WAIT, - SCAN_SRV_STATE_SCANNING, - SCAN_SRV_STATE_STOPPING, - SCAN_SRV_STATE_PS_EXIT, - SCAN_SRV_NUM_OF_STATES -} scan_SRVSMStates_e; - -/* - *********************************************************************** - * Typedefs. - *********************************************************************** - */ - -/* - *********************************************************************** - * Structure definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External data definitions. - *********************************************************************** - */ - -/* - *********************************************************************** - * External functions definitions - *********************************************************************** - */ - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Initialize the scan SRV SM. - * - * Function Scope \e Public.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_init( TI_HANDLE hScanSrv ); - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Processes an event. - * - * Function Scope \e Public.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \param currentState - the current scan SRV SM state.\n - * \param event - the event to handle.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_SMEvent( TI_HANDLE hScanSrv, scan_SRVSMStates_e* currentState, - scan_SRVSMEvents_e event ); - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Request to enter driver mode from the power manager module.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_requestPS( TI_HANDLE hScanSrv ); - -/** - * \author Yuval Adler\n - * \date 6-Oct-2005\n - * \brief Request to release PS mode from the PowerSRV , and wait for answer.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_releasePS( TI_HANDLE hScanSrv ); - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Send the scan command to the firmware.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_startActualScan( TI_HANDLE hScanSrv ); - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Send a stop scan command to the firmware.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_stopActualScan( TI_HANDLE hScanSrv ); - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Notifies scan complete to upper layer.\n - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_notifyScanComplete( TI_HANDLE hScanSrv ); - -/** - * \author Ronen Kalish\n - * \date 10-Jan-2005\n - * \brief Handles a timer expiry event - starts a recovery process. - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_handleTimerExpiry( TI_HANDLE hScanSrv ); - -/** - * \author Ronen Kalish\n - * \date 17-Jan-2005\n - * \brief Handles a FW reset event (one that was detected outside the scan SRV) by stopping the timer. - * - * Function Scope \e Private.\n - * \param hScanSrv - handle to the scan SRV object.\n - * \return TI_OK if successful, TI_NOK otherwise.\n - */ -TI_STATUS scanSRVSM_handleRecovery( TI_HANDLE hScanSrv ); - -#endif /* __SCANSRVSM_H__ */ diff --git a/wl1271/TWD/MacServices/measurementSrvDbgPrint.c b/wl1271/TWD/MacServices/measurementSrvDbgPrint.c deleted file mode 100644 index aef32631..00000000 --- a/wl1271/TWD/MacServices/measurementSrvDbgPrint.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * measurementSrvDbgPrint.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** \file measurementSrvDbgPrint.c - * \brief This file include variuos measurement SRV debug print facilities - * \author Ronen Kalish - * \date 23-December-2005 - */ - -#define __FILE_ID__ FILE_ID_111 -#include "report.h" -#include "TWDriver.h" -#include "MeasurementSrvSM.h" -#include "MeasurementSrv.h" -#include "measurementSrvDbgPrint.h" - - -/** - * \author Ronen Kalish\n - * \date 23-December-2005\n - * \brief Prints a measurement request.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param pMsrRequest - the measurement request.\n - */ -void measurementSRVPrintRequest( TI_HANDLE hMeasurementSRV, TMeasurementRequest *pMsrRequest ) -{ -#ifdef TI_DBG - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - TI_INT32 i; - -TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "Measurement request:\n"); -TRACE5( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "band: %d, channel:%d, TX power level: %d, start time: %x-%x\n", pMsrRequest->band, pMsrRequest->channel, pMsrRequest->txPowerDbm, INT64_HIGHER(pMsrRequest->startTime), INT64_LOWER(pMsrRequest->startTime)); - for ( i = 0; i < pMsrRequest->numberOfTypes; i++ ) - { - measurementSRVPrintTypeRequest( hMeasurementSRV, &(pMsrRequest->msrTypes[ i ])); - } -#endif /* TI_DBG */ - -} - -/** - * \author Ronen Kalish\n - * \date 23-December-2005\n - * \brief Prints a measurement type request.\n - * - * Function Scope \e Public.\n - * \param hMeasurementSRV - handle to the measurement SRV object.\n - * \param pMsrTypeRequest - the measurement type request.\n - */ -void measurementSRVPrintTypeRequest( TI_HANDLE hMeasurementSRV, TMeasurementTypeRequest* pMsrTypeRequest ) -{ -#ifdef TI_DBG - measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; - -TRACE4( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "Measurement type request: type: %d, duration:%d, scan mode: %d, reserved: %d", pMsrTypeRequest->msrType, pMsrTypeRequest->duration, pMsrTypeRequest->scanMode, pMsrTypeRequest->reserved); - -#endif /* TI_DBG */ -} - |